def plot_cdf_from_file(filename):
    """Open file, store cdf to .pdf and .png"""

    import numpy as np
    import matplotlib.pyplot as plt
    data = np.genfromtxt(filename, delimiter=',')

    # convert zeros to nans and clear empty rows
    data[np.where(data==0)] = np.nan
    data = data[~np.isnan(data).all(1)]
    if not data.size:
        print 'No data in ' + str(filename)

    # SINR data is best presented in dB
    from utils import utils
    data = utils.WTodB(data)
    
    import cdf_plot
    label = [ "Iteration %d" %i for i in np.arange(data.shape[0])+1]
    cdf_plot.cdf_plot(data, '-', label=label)
#    plt.xlabel(xlabel)
#    plt.ylabel(ylabel)
#    plt.title(title)
    plt.savefig(filename+'.pdf', format='pdf')
    plt.savefig(filename+'.png', format='png')
def plot_cdf_from_file(filename):
    """Open file, store cdf to .pdf and .png"""

    import numpy as np
    import matplotlib.pyplot as plt
    data = np.genfromtxt(filename, delimiter=',')

    # convert zeros to nans and clear empty rows
    data[np.where(data == 0)] = np.nan
    data = data[~np.isnan(data).all(1)]
    if not data.size:
        print 'No data in ' + str(filename)

    # SINR data is best presented in dB
    from utils import utils
    data = utils.WTodB(data)

    import cdf_plot
    label = ["Iteration %d" % i for i in np.arange(data.shape[0]) + 1]
    cdf_plot.cdf_plot(data, '-', label=label)
    #    plt.xlabel(xlabel)
    #    plt.ylabel(ylabel)
    #    plt.title(title)
    plt.savefig(filename + '.pdf', format='pdf')
    plt.savefig(filename + '.png', format='png')
Пример #3
0
def plot_files( files ):
    
    # and now plot
    pylab.figure()
    
    colors = "bgrkmcy"
    markers = "sod^v*<>"
    if options.nolines:
        lines = "         "
    else:
        lines = [ "-", "--", ":", "-.", "-","--",":" ]
    i=0
    legend_text = []
    file_labels = None
    if options.file_label:
            file_labels=options.file_label.split(";")
        
    current_file_index = 0
    for file in files:
        print "processing %s..."%file

        values=read_values( file )
        
        #print values
        # need to build nice vectors for each of the y-values
        x=numpy.array( sorted( values.keys() ) )
        legend=options.legend.strip().split(",")
        for j in xrange( 0,len(legend),2 ):
            #print legend[j]
            y=[]
            err=[]
            legend_text.append( legend[j+1] )
            for xx in x:
                y.append( values[xx][legend[j]] )
                std_label = legend[j]+"_ci"
                if std_label in values[xx]:
                    err.append( values[xx][std_label] )
                
            y=numpy.array(y)
            err=numpy.array(err)
            
            additional_text=""
            if file_labels:
                additional_text = file_labels[current_file_index]
            if options.cdf:
                cdf_plot.cdf_plot( y, linestyle=lines[i], marker=markers[i],color=colors[i], label=legend_text[i]+additional_text, linewidth=2 )
            elif options.errbars:
                pylab.errorbar( x,y, [err,err], linestyle=lines[i], marker=markers[i],color=colors[i], label=legend_text[i]+additional_text, linewidth=2 )
            else:
                pylab.plot( x,y , linestyle=lines[i], color=colors[i], marker=markers[i],label=legend_text[i]+additional_text, linewidth=2 )
            
            i+=1
        
        current_file_index+=1
        
    #print legend_text
    export_fig( options.xlabel, options.ylabel, [])
Пример #4
0
def plot_cdf_from_file(filename):
    """Open file, store cdf to .pdf and .png"""

    import numpy as np
    import matplotlib.pyplot as plt
    import pylab as P
    data = np.genfromtxt(filename, delimiter=',')

    # SINR data is best presented in dB
    from utils import utils
    data = utils.WTodB(data)

    import cdf_plot
    label = ["Iteration %d" % i for i in np.arange(data.shape[0]) + 1]
    cdf_plot.cdf_plot(data, '-', label=label)
    #    plt.xlabel(xlabel)
    #    plt.ylabel(ylabel)
    #    plt.title(title)
    P.arrow(0, 50, 40, 0, fc="k", ec="k", head_width=3, head_length=5)
    plt.savefig(filename + '.pdf', format='pdf')
    plt.savefig(filename + '.png', format='png')
Пример #5
0
def plot_cdf_from_file(filename):
    """Open file, store cdf to .pdf and .png"""

    import numpy as np
    import matplotlib.pyplot as plt
    import pylab as P
    data = np.genfromtxt(filename, delimiter=',')

    # SINR data is best presented in dB
    from utils import utils
    data = utils.WTodB(data)
    
    import cdf_plot
    label = [ "Iteration %d" %i for i in np.arange(data.shape[0])+1]
    cdf_plot.cdf_plot(data, '-', label=label)
#    plt.xlabel(xlabel)
#    plt.ylabel(ylabel)
#    plt.title(title)
    P.arrow( 0, 50, 40, 0, fc="k", ec="k",
            head_width=3, head_length=5 )
    plt.savefig(filename+'.pdf', format='pdf')
    plt.savefig(filename+'.png', format='png')