<commit_before>"""
All functions related to plotting
"""

import numpy as np
import networkx as nx

import matplotlib as mpl
import matplotlib.pylab as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable


def plot_matrix(mat, ax):
    """ Plot system evolution
    """
    cmap = plt.cm.coolwarm
    cmap.set_under('white')

    im = ax.imshow(
        mat, vmin=0,
        interpolation='nearest', cmap=cmap)

    divider = make_axes_locatable(ax)
    cax = divider.append_axes('right', size='5%', pad=0.2)
    plt.colorbar(im, cax=cax)

    ax.set_xlabel(r'$i$')
    ax.set_ylabel(r'$j$')

    ax.set_title('Sign-switch of dynamic connectivity matrix')

def plot_graph(graph, ax):
    """ Plot graph
    """
    # generate some node properties
    labels = {}
    for n in graph.nodes():
        labels[n] = n

    # compute layout
    pos = nx.nx_pydot.graphviz_layout(graph, prog='neato')

    # draw graph
    nx.draw(
        graph, pos,
        node_color='lightskyblue', node_size=800,
        font_size=20,
        ax=ax)
    nx.draw_networkx_labels(graph, pos, labels)

def plot_evolutions(sols, ts, ax):
    """ Plot system evolution
    """
    for i, sol in enumerate(sols):
        ax.plot(ts, sol, label=r'$f_{{{}}}$'.format(i))

    ax.set_xlabel(r'$t$')
    ax.set_ylabel(r'$\Theta_i$')

    ax.set_ylim((0, 2*np.pi))
    #ax.legend(loc='best')

def plot_correlation_matrix(cmat, ts, ax):
    """ Plot individual correlation matrix
    """
    for i, row in enumerate(cmat):
        for j, sol in enumerate(row):
            ax.plot(ts, sol, label='{},{}'.format(i, j))

    ax.set_xlabel(r'$t$')
    ax.set_ylabel(r'$\langle \cos \left(\Theta_i(t) - \Theta_j(t)\right)\rangle$')
    ax.set_ylim((-1, 1.1))<commit_msg>Change evolution plot<commit_after>"""
All functions related to plotting
"""

import numpy as np
import networkx as nx

import matplotlib as mpl
import matplotlib.pylab as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable


def plot_matrix(mat, ax):
    """ Plot system evolution
    """
    cmap = plt.cm.coolwarm
    cmap.set_under('white')

    im = ax.imshow(
        mat, vmin=0,
        interpolation='nearest', cmap=cmap)

    divider = make_axes_locatable(ax)
    cax = divider.append_axes('right', size='5%', pad=0.2)
    plt.colorbar(im, cax=cax)

    ax.set_xlabel(r'$i$')
    ax.set_ylabel(r'$j$')

    ax.set_title('Sign-switch of dynamic connectivity matrix')

def plot_graph(graph, ax):
    """ Plot graph
    """
    # generate some node properties
    labels = {}
    for n in graph.nodes():
        labels[n] = n

    # compute layout
    pos = nx.nx_pydot.graphviz_layout(graph, prog='neato')

    # draw graph
    nx.draw(
        graph, pos,
        node_color='lightskyblue', node_size=800,
        font_size=20,
        ax=ax)
    nx.draw_networkx_labels(graph, pos, labels)

def plot_evolutions(sols, ts, ax):
    """ Plot system evolution
    """
    ax.imshow(
        sols, aspect='auto',
        cmap=plt.cm.gray, interpolation='nearest')

    ax.set_xlabel(r'$t$')
    ax.set_ylabel(r'$\Theta_i$')

def plot_correlation_matrix(cmat, ts, ax):
    """ Plot individual correlation matrix
    """
    for i, row in enumerate(cmat):
        for j, sol in enumerate(row):
            ax.plot(ts, sol, label='{},{}'.format(i, j))

    ax.set_xlabel(r'$t$')
    ax.set_ylabel(r'$\langle \cos \left(\Theta_i(t) - \Theta_j(t)\right)\rangle$')
    ax.set_ylim((-1, 1.1))
{'fraction_non_alphanumeric': 0.15020337013364324, 'fraction_numerical': 0.008134805345729227, 'mean_word_length': 2.9849537037037037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1614218', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1255, 'n_words': 271}