Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • b4656680675c87d480c4cf8e93171254d1addd5f
  • master par défaut protégée
  • rust-playlist-sync
  • rust
  • fix-qt-deprecated-qvariant-type
  • fix-mpris-qtwindow-race-condition
  • rust-appimage-wayland
  • windows-build-rebased
  • v2.5 protégée
  • v2.4 protégée
  • v2.3-1 protégée
  • v2.3 protégée
  • v2.2 protégée
  • v2.1 protégée
  • v2.0 protégée
  • v1.8-3 protégée
  • v1.8-2 protégée
  • v1.8-1 protégée
  • v1.8 protégée
  • v1.7 protégée
  • v1.6 protégée
  • v1.5 protégée
  • v1.4 protégée
  • v1.3 protégée
  • v1.2 protégée
  • v1.1 protégée
  • v1.0 protégée
27 résultats

common.h

Blame
  • graph.py 3,49 Kio
    """
    Module for graphing
    """
    
    import matplotlib.pyplot as plt
    import numpy as np
    import seaborn as sns
    
    def hist_distributivity_graph(N,RESOLUTION,seed,data):
        """
        graphs histograms
        see values function in main module
        """
        plt.clf()
        for name in data:
            print("building "+str(name)+" histogram...")
            xlabel= "Value"
            ylabel="Count"
            title_name= name +"\n N = "+str(N)+"\n seed = "+str(seed) 
            graph=sns.displot(data[name], kde=True)
            graph.set(title=title_name)
            graph.set_axis_labels(xlabel,ylabel)
            graph.savefig(name+'_hist.png', bbox_inches='tight')
        return
    
    def ecdf_graph(N,RESOLUTION,seed,data):
        """
        graphs histograms
        see values function in main module
        """
        plt.clf()
        for name in data:
            print("building "+str(name)+" ecdf...")
            xlabel= "Value"
            ylabel="Cumulative Probability"
            title_name= name +"\n N = "+str(N)+"\n seed = "+str(seed) 
            if N==0:
                title_name= name +"\n seed = "+str(seed) 
            graph=sns.displot(data[name], kind="ecdf")
            graph.set(title=title_name)
            graph.set_axis_labels(xlabel,ylabel)
            graph.savefig(name+'_ecdf.png', bbox_inches='tight')
        return
    
    def compare_ecdf(N, RESOLUTION, seed, data):
        """
        Create graphs superposing  ecdf   
        """
        plt.clf()
        BW = 0.337
        name = "compare_ecdf_"
        for e in data:
            name += e+"_"
        
        #subdata = {k : data[k] for k in names}  
        print("graphing "+str(name)+"...")
        
        xlabel = "Value"
        ylabel = "Density"
        title_name="N = "+str(N)+"\n seed = "+str(seed)
        if N == 0:
            title_name = "seed = "+str(seed)
        graph=sns.displot(data,legend=True
                            , kind="ecdf")
        graph.set(title=title_name)
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        #plt.legend()
        plt.savefig(name+'.png', bbox_inches='tight')    
        return
    
    def compare(N, RESOLUTION, seed, data):
        """
        Create graphs superposing two, already generated,
        distributivity
        """
        plt.clf()
        BW = 0.337
        name = "compare_"
        for e in data:
            name += e+"_"
        
        #subdata = {k : data[k] for k in names}  
        print("graphing "+str(name)+"...")
        
        xlabel = "Value"
        ylabel = "Density"
        title_name="N = "+str(N)+"\n seed = "+str(seed)
        if N == 0:
            title_name = "seed = "+str(seed)
        for e in data:
            graph=sns.kdeplot(data[e],legend=True,bw_adjust=BW,common_norm=False
                              ,label=str(e))
        graph.set(title=title_name)
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        graph.axes.set
        plt.legend()
        plt.savefig(name+'.png', bbox_inches='tight')
        return
    
    def lineplot_wrap(data, xlabel, ylabel, title, iterN):
        plt.clf()
        print("graphing "+str(title)+"...")
        for e in data:
            plt.plot(iterN, data[e], marker="o", label="seed="+str(e))
        #graph = sns.lineplot(data, legend=True, x=iterN)
        plt.title(title)
        plt.legend()
        plt.xscale('log')
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        plt.savefig(title.replace(" ", "_")+".png", bbox_inches="tight")
    
    def lineplot_mean_alot(data, xlabel, ylabel, title, iterN):
        plt.clf()
        print("graphing "+str(title)+"...")
        for e in data:
            plt.plot(iterN, data[e], marker="o", alpha=0.05
                     , color="red")
        plt.plot(iterN, [0.5]*len(iterN), color="blue",linestyle='dotted')
        plt.title(title)
        plt.xscale('log')
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        plt.savefig(title+".png", bbox_inches="tight")