def save_plotSpectrum(y,Fs,image_name):
    """
    Plots a Single-Sided Amplitude Spectrum of y(t)
    """
    fig = Figure(linewidth=0.0)
    fig.set_size_inches(fig_width,fig_length, forward=True)
    Figure.subplots_adjust(fig, left = fig_left, right = fig_right, bottom = fig_bottom, top = fig_top, hspace = fig_hspace)
    n = len(y) # length of the signal

    _subplot = fig.add_subplot(2,1,1)        
    print "Fi"
    _subplot.plot(arange(0,n),y)
    xlabel('Time')
    ylabel('Amplitude')
    _subploti_2=fig.add_subplot(2,1,2)
    k = arange(n)
    T = n/Fs
    frq = k/T # two sides frequency range
    frq = frq[range(n/2)] # one side frequency range

    Y = fft(y)/n # fft computing and normalization
    Y = Y[range(n/2)]

    _subplot_2.plot(frq,abs(Y),'r') # plotting the spectrum
    xlabel('Freq (Hz)')
    ylabel('|Y(freq)|')
    print "here"
    canvas = FigureCanvasAgg(fig)
    if '.eps' in outfile_name:
        canvas.print_eps(outfile_name, dpi = 110)
    if '.png' in outfile_name:
        canvas.print_figure(outfile_name, dpi = 110)
def print_image(x, y, x2, y2, outfile_name):
    fig = Figure(linewidth=0.0)
    fig.set_size_inches(fig_width, fig_length, forward=True)
    Figure.subplots_adjust(fig,
                           left=fig_left,
                           right=fig_right,
                           bottom=fig_bottom,
                           top=fig_top,
                           hspace=fig_hspace)
    _subplot = fig.add_subplot(2, 1, 1)
    _subplot.set_title('Detection of Source generating non-wifi Interference')
    _subplot.plot(x, y, color='b')
    _subplot.set_xlabel('Time')
    _subplot.set_ylabel('Error Counts')
    #    _subplot.set_ylim([0,1])
    _subplot2 = fig.add_subplot(2, 1, 2)
    _subplot2.plot(x2, y2, color='r')  # plotting the spectrum
    _subplot2.set_ylabel('Entropy')
    _subplot2.set_xlabel('Time')
    _subplot2.set_ylim([0, 1])
    canvas = FigureCanvasAgg(fig)
    if '.eps' in outfile_name:
        canvas.print_eps(outfile_name, dpi=110)
    if '.png' in outfile_name:
        canvas.print_figure(outfile_name, dpi=110)
Exemple #3
0
def template_plotter(x_axis_label, y_axis_label,x_axes=[],x_ticks=[],title, outfile_name):
    fig = Figure(linewidth=0.0)
    fig.set_size_inches(fig_width,fig_length, forward=True)
    Figure.subplots_adjust(fig, left = fig_left, right = fig_right, bottom = fig_bottom, top = fig_top, hspace = fig_hspace)

    _subplot = fig.add_subplot(1,1,1)
    _subplot.boxplot(x_axis,notch=0,sym='+',vert=1, whis=1.5)    
    #_subplot.plot(x,y,color='b', linestyle='--', marker='o' ,label='labels')
    a =[i for i in range(1,len(x_ticks)+1)]
    _subplot.set_xticklabels(x_ticks)
    _subplot.set_xticks(a)
    labels=_subplot.get_xticklabels()
    for label in labels:
        label.set_rotation(30)
    _subplot.set_ylabel(y_axis_label,fontsize=36)
    _subplot.set_xlabel(x_axis_label)
    #_subplot.set_ylim()
    #_subplot.set_xlim()
    
    _subplot.set_title(title)
    _subplot.legend(loc='upper left',prop=LEGEND_PROP ,bbox_to_anchor=(0.5, -0.05))
    canvas = FigureCanvasAgg(fig)
    if '.eps' in outfile_name:
        canvas.print_eps(outfile_name, dpi = 110)
    if '.png' in outfile_name:
        canvas.print_figure(outfile_name, dpi = 110)
    outfile_name='EpsilonvsMTU.pdf'
    if '.pdf' in outfile_name:
        canvas.print_figure(outfile_name, dpi = 110)
def print_figure(fig, destination_directory, filename, extension):
    canvas = FigureCanvasAgg(fig)
    if extension == '.png':
        canvas.print_figure(os.path.join(destination_directory, \
            filename + extension), dpi = 110)
    elif extension == '.eps':
        canvas.print_eps(os.path.join(destination_directory,\
            filename + extension), dpi = 110)
Exemple #5
0
def print_figure(fig, destination_directory, filename, extension):
    canvas = FigureCanvasAgg(fig)
    if extension == '.png':
        canvas.print_figure(os.path.join(destination_directory, \
            filename + extension), dpi = 110)
    elif extension == '.eps':
        canvas.print_eps(os.path.join(destination_directory,\
            filename + extension), dpi = 110)
def print_image(x,y,x2,y2,outfile_name):
    fig = Figure(linewidth=0.0)
    fig.set_size_inches(fig_width,fig_length, forward=True)
    Figure.subplots_adjust(fig, left = fig_left, right = fig_right, bottom = fig_bottom, top = fig_top, hspace = fig_hspace)
    _subplot = fig.add_subplot(2,1,1)
    _subplot.set_title('Detection of Source generating non-wifi Interference')
    _subplot.plot(x,y,color='b')
    _subplot.set_xlabel('Time')
    _subplot.set_ylabel('Error Counts')
#    _subplot.set_ylim([0,1])
    _subplot2=fig.add_subplot(2,1,2)
    _subplot2.plot(x2,y2,color='r') # plotting the spectrum                     
    _subplot2.set_ylabel('Entropy')
    _subplot2.set_xlabel('Time')
    _subplot2.set_ylim([0,1])
    canvas = FigureCanvasAgg(fig)
    if '.eps' in outfile_name:
        canvas.print_eps(outfile_name, dpi = 110)
    if '.png' in outfile_name:
        canvas.print_figure(outfile_name, dpi = 110)
def save_plotSpectrum(y, Fs, image_name):
    """
    Plots a Single-Sided Amplitude Spectrum of y(t)
    """
    fig = Figure(linewidth=0.0)
    fig.set_size_inches(fig_width, fig_length, forward=True)
    Figure.subplots_adjust(fig,
                           left=fig_left,
                           right=fig_right,
                           bottom=fig_bottom,
                           top=fig_top,
                           hspace=fig_hspace)
    n = len(y)  # length of the signal

    _subplot = fig.add_subplot(2, 1, 1)
    print "Fi"
    _subplot.plot(arange(0, n), y)
    xlabel('Time')
    ylabel('Amplitude')
    _subploti_2 = fig.add_subplot(2, 1, 2)
    k = arange(n)
    T = n / Fs
    frq = k / T  # two sides frequency range
    frq = frq[range(n / 2)]  # one side frequency range

    Y = fft(y) / n  # fft computing and normalization
    Y = Y[range(n / 2)]

    _subplot_2.plot(frq, abs(Y), 'r')  # plotting the spectrum
    xlabel('Freq (Hz)')
    ylabel('|Y(freq)|')
    print "here"
    canvas = FigureCanvasAgg(fig)
    if '.eps' in outfile_name:
        canvas.print_eps(outfile_name, dpi=110)
    if '.png' in outfile_name:
        canvas.print_figure(outfile_name, dpi=110)
Exemple #8
0
def save_to_eps(fig, output_file):
    fig.set_facecolor("#FFFFFF")
    canvas = FigureCanvasAgg(fig)
    canvas.print_eps(output_file, dpi=72)
Exemple #9
0
def save_to_eps(fig, output_file):
    fig.set_facecolor("#FFFFFF")
    canvas = FigureCanvasAgg(fig)
    canvas.print_eps(output_file, dpi=72)
temp = [d.temp for d in data]
lux = [d.lux for d in data]

fig = matplotlib.figure.Figure()
hplot = fig.add_subplot(3,1,1)
tplot = fig.add_subplot(3,1,2)
lplot = fig.add_subplot(3,1,3)

hplot.plot_date(dates, hum)
tplot.plot_date(dates, temp)
lplot.plot_date(dates, lux)

hplot.xaxis.set_major_locator(matplotlib.dates.DayLocator())
hplot.xaxis.set_minor_locator(matplotlib.dates.HourLocator(numpy.arange(0,24,1)))
hplot.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y-%m-%d'))
tplot.xaxis.set_major_locator(matplotlib.dates.DayLocator())
tplot.xaxis.set_minor_locator(matplotlib.dates.HourLocator(numpy.arange(0,24,1)))
tplot.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y-%m-%d'))
lplot.xaxis.set_major_locator(matplotlib.dates.DayLocator())
lplot.xaxis.set_minor_locator(matplotlib.dates.HourLocator(numpy.arange(0,24,1)))
lplot.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y-%m-%d'))

canvas = FigureCanvasAgg(fig)
canvas.print_eps(output, dpi=110)

of = open('export.csv', 'w')
of.write('Humidity,Temperature,Luminosity,Date\n')
for d in data:
    of.write('%.2f,%.2f,%d,%s\n' % (d.hum, d.temp, d.lux / 20000.0, d.time.strftime('%m/%d/%Y %H:%M')))
of.close()
Exemple #11
0
lines = p.loglog(getXvals(times_L), getYvals(times_L), 'ro-', getXvals(times_L_ideal), getYvals(times_L_ideal), 'r:', \
   getXvals(times_E), getYvals(times_E), 'bo-', getXvals(times_E_ideal), getYvals(times_E_ideal), 'b:', \
   getXvals(times_B), getYvals(times_B), 'go-', getXvals(times_B_ideal), getYvals(times_B_ideal), 'g:', \
   getXvals(times_M), getYvals(times_M), 'ko-', getXvals(times_M_ideal), getYvals(times_M_ideal), 'k:', \
   getXvals(times_Lm), getYvals(times_Lm), 'mo-', getXvals(times_Lm_ideal), getYvals(times_Lm_ideal), 'm:')

p.set_ylabel('Simulation time for 1 sec of net activity (sec)', fontsize=14)

p.set_xlabel('Number of processors', fontsize=14)

lines[0].set_label('Legion')
lines[2].set_label('PadraigPC')
lines[4].set_label('Bernal')
lines[6].set_label('Matthau')
lines[8].set_label('Lemmon')

legend()

fig.set_figheight(8)
fig.set_figwidth(12)

#plt.print_figure()

canvas = FigureCanvas(fig)

canvas.print_eps('Performance.eps')

print dir(fig)

plt.show()
Exemple #12
0
    pArr = []
    data_x = np.arange(0.0, 100.0, 1)
    data_y = np.arange(0.0, 100.0, 1)
    for alab in legendColors:
        # p = Rectangle((0, 0), 1, 1, fc="r")
        # l = Line2D(ax, data_x, data_y , color=plotcolors[alab % len(plotcolors)], ls='-', lw=2)
        l = Rectangle((0, 0), 1, 1, fc=plotcolors[alab % len(plotcolors)])
        pArr.append(l)
        #pArr.append(  ax.plot(data_x, data_y, color=plotcolors[colorParams % len(plotcolors)], linestyle='-', marker='', markerfacecolor='None', markeredgecolor='#000000' )  )
    legend(pArr, legendText)
    canvas = FigureCanvas(fig)
    targetFile = targetList[0]
    graphicsFilename = targetFile
    graphicsFilename = graphicsFilename.replace('.txt', '')
    #canvas.print_eps(graphicsFilename+'.svg')
    canvas.print_eps(graphicsFilename + '.eps')
    #canvas.print_pdf(graphicsFilename+'.pdf')
    canvas.print_png(graphicsFilename + '.png')
    plt.close(fig)

# for each file sent as argument create a plot
for filidx in range(0, len(targetList)):
    targetFile = targetList[filidx]
    # read the x values
    if (os.path.exists(targetFile)):
        # read the y values
        data_y = []
        data_x = []
        t = 0
        if (dtfileFlag and os.path.exists(dtfileParams)):
            file_x = open(dtfileParams, 'rU')
    pArr = []
    data_x = np.arange(0.0, 100.0, 1)
    data_y = np.arange(0.0, 100.0, 1)
    for alab in legendColors:
        # p = Rectangle((0, 0), 1, 1, fc="r")
        # l = Line2D(ax, data_x, data_y , color=plotcolors[alab % len(plotcolors)], ls='-', lw=2)
        l = Rectangle((0, 0), 1, 1, fc=plotcolors[alab % len(plotcolors)])
        pArr.append(l)
        #pArr.append(  ax.plot(data_x, data_y, color=plotcolors[colorParams % len(plotcolors)], linestyle='-', marker='', markerfacecolor='None', markeredgecolor='#000000' )  )
    legend(pArr, legendText)
    canvas = FigureCanvas(fig)
    targetFile = targetList[0]
    graphicsFilename = targetFile
    graphicsFilename = graphicsFilename.replace('.txt','')
    #canvas.print_eps(graphicsFilename+'.svg')
    canvas.print_eps(graphicsFilename+'.eps')
    #canvas.print_pdf(graphicsFilename+'.pdf')
    canvas.print_png(graphicsFilename+'.png')
    plt.close(fig)

# for each file sent as argument create a plot
for filidx in range(0,len(targetList)):
    targetFile = targetList[filidx]
    # read the x values
    if (os.path.exists(targetFile) ):
        # read the y values
        data_y = []
        data_x = []
        t = 0
        if (dtfileFlag and os.path.exists(dtfileParams)):
            file_x = open(dtfileParams,'rU')

p.set_ylabel('Simulation time for 1 sec of net activity (sec)', fontsize=14)

p.set_xlabel('Number of processors', fontsize=14)


lines[0].set_label('Legion')
lines[2].set_label('PadraigPC')
lines[4].set_label('Bernal')
lines[6].set_label('Matthau')
lines[8].set_label('Lemmon')

legend()

fig.set_figheight(8)
fig.set_figwidth(12)

#plt.print_figure()

canvas = FigureCanvas(fig)

canvas.print_eps('Performance.eps')

print dir(fig)


plt.show()


Exemple #15
0
    #done with creation
    #width=0.35
    #import numpy as np
    #ind = np.arange(len(homes))        
    #rects=_subplot.bar(ind,percentile,width,color='blue')
    #_subplot.set_ylabel('Delay(90th percentile)')        
    g=[]
    for i in z : 
        g.append(str(i))
    #_subplot.set_xticks(ind+width)
    #_subplot.set_xticklabels(g)
    #_subplot.legend(loc=0, prop=LEGEND_PROP, bbox_to_anchor=(0.1,- 0.05), scatterpoints=1)
    #aray.append(rects[0])
    #legend_elem=file.strip('pickle.')
    #legend_elem=legend_elem.strip('^rate_')
    #legend.append(legend_elem)
    #print legend
    #print "========"
    #print aray
    labels = _subplot.get_xticklabels()
    for label in labels:
        label.set_rotation(30)

    _subplot.legend(loc=0, prop=LEGEND_PROP,bbox_to_anchor=(0.1,- 0.05))
    canvas = FigureCanvasAgg(fig)
    if '.eps' in outfile_name:
        canvas.print_eps(outfile_name, dpi = 110)
    if '.png' in outfile_name:
        canvas.print_figure(outfile_name, dpi = 110)

Exemple #16
0
    _subplot.set_ylabel('Delay(mean) between frames in microseconds')            
    '''
    g=[]
    aray=[]
    for i in z : 
        g.append(str(i))
    _subplot.set_xticks(ind+width)
    _subplot.set_xticklabels(g)
    #_subplot.legend(loc=0, prop=LEGEND_PROP, bbox_to_anchor=(0.1,- 0.05), scatterpoints=1)
    aray.append(rects[0])
    _subplot.set_yscale('log')
    #legend_elem=file.strip('pickle.')
    #legend_elem=legend_elem.strip('^rate_')
    #legend.append(legend_elem)
    #print legend
    #print "========"
    #print aray
    #if len(aray) > 0:
     #   _subplot.legend(aray,legend)#,bbox_to_anchor=(0.1,- 0.05))
    labels = _subplot.get_xticklabels()
    for label in labels:
        label.set_rotation(30)


    canvas = FigureCanvasAgg(fig)
    if '.eps' in outfile_name:
        canvas.print_eps(outfile_name, dpi = 110)
    if '.png' in outfile_name:
        canvas.print_figure(outfile_name, dpi = 110)

    getXvals(times_Lm_ideal),
    getYvals(times_Lm_ideal),
    "m:",
)


p.set_ylabel("Simulation time for 1 sec of net activity (sec)", fontsize=14)

p.set_xlabel("Number of processors", fontsize=14)


lines[0].set_label("Lemmon")
lines[2].set_label("Matthau")
lines[4].set_label("Both")

legend()

fig.set_figheight(8)
fig.set_figwidth(12)

# plt.print_figure()

canvas = FigureCanvas(fig)

canvas.print_eps("Performance.eps")

# print dir(fig)


plt.show()