本文整理汇总了Python中pylab.plt.show函数的典型用法代码示例。如果您正苦于以下问题:Python show函数的具体用法?Python show怎么用?Python show使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: example_filterbank
def example_filterbank():
from pylab import plt
import numpy as np
x = _create_impulse(2000)
gfb = GammatoneFilterbank(density=1)
analyse = gfb.analyze(x)
imax, slopes = gfb.estimate_max_indices_and_slopes()
fig, axs = plt.subplots(len(gfb.centerfrequencies), 1)
for (band, state), imx, ax in zip(analyse, imax, axs):
ax.plot(np.real(band))
ax.plot(np.imag(band))
ax.plot(np.abs(band))
ax.plot(imx, 0, 'o')
ax.set_yticklabels([])
[ax.set_xticklabels([]) for ax in axs[:-1]]
axs[0].set_title('Impulse responses of gammatone bands')
fig, ax = plt.subplots()
def plotfun(x, y):
ax.semilogx(x, 20*np.log10(np.abs(y)**2))
gfb.freqz(nfft=2*4096, plotfun=plotfun)
plt.grid(True)
plt.title('Absolute spectra of gammatone bands.')
plt.xlabel('Normalized Frequency (log)')
plt.ylabel('Attenuation /dB(FS)')
plt.axis('Tight')
plt.ylim([-90, 1])
plt.show()
return gfb
开发者ID:SiggiGue,项目名称:pyfilterbank,代码行数:35,代码来源:gammatone.py
示例2: pure_data_plot
def pure_data_plot(self,connect=False,suffix='',cmap=cm.jet,bg=cm.bone(0.3)):
#fig=plt.figure()
ax=plt.axes()
plt.axhline(y=0,color='grey', zorder=-1)
plt.axvline(x=0,color='grey', zorder=-2)
if cmap is None:
if connect: ax.plot(self.x,self.y, 'b-',lw=2,alpha=0.5)
ax.scatter(self.x,self.y, marker='o', c='b', s=40)
else:
if connect:
if cmap in [cm.jet,cm.brg]:
ax.plot(self.x,self.y, 'c-',lw=2,alpha=0.5,zorder=-1)
else:
ax.plot(self.x,self.y, 'b-',lw=2,alpha=0.5)
c=[cmap((f-self.f[0])/(self.f[-1]-self.f[0])) for f in self.f]
#c=self.f
ax.scatter(self.x, self.y, marker='o', c=c, edgecolors=c, zorder=True, s=40) #, cmap=cmap)
#plt.axis('equal')
ax.set_xlim(xmin=-0.2*amax(self.x), xmax=1.2*amax(self.x))
ax.set_aspect('equal') #, 'datalim')
if cmap in [cm.jet,cm.brg]:
ax.set_axis_bgcolor(bg)
if self.ZorY == 'Z':
plt.xlabel(r'resistance $R$ in Ohm'); plt.ylabel(r'reactance $X$ in Ohm')
if self.ZorY == 'Y':
plt.xlabel(r'conductance $G$ in Siemens'); plt.ylabel(r'susceptance $B$ in Siemens')
if self.show: plt.show()
else: plt.savefig(join(self.sdc.plotpath,'c{}_{}_circle_data'.format(self.sdc.case,self.ZorY)+self.sdc.suffix+self.sdc.outsuffix+suffix+'.png'), dpi=240)
plt.close()
开发者ID:antiface,项目名称:zycircle,代码行数:29,代码来源:ZYCircle.py
示例3: draw
def draw(cls, t_max, agents_proportions, eco_idx, parameters):
color_set = ["green", "blue", "red"]
for agent_type in range(3):
plt.plot(np.arange(t_max), agents_proportions[:, agent_type],
color=color_set[agent_type], linewidth=2.0, label="Type-{} agents".format(agent_type))
plt.ylim([-0.1, 1.1])
plt.xlabel("$t$")
plt.ylabel("Proportion of indirect exchanges")
# plt.suptitle('Direct choices proportion per type of agents', fontsize=14, fontweight='bold')
plt.legend(loc='upper right', fontsize=12)
print(parameters)
plt.title(
"Workforce: {}, {}, {}; displacement area: {}; vision area: {}; alpha: {}; tau: {}\n"
.format(
parameters["x0"],
parameters["x1"],
parameters["x2"],
parameters["movement_area"],
parameters["vision_area"],
parameters["alpha"],
parameters["tau"]
), fontsize=12)
if not path.exists("../../figures"):
mkdir("../../figures")
plt.savefig("../../figures/figure_{}.pdf".format(eco_idx))
plt.show()
开发者ID:AurelienNioche,项目名称:SpatialEconomy,代码行数:35,代码来源:analysis_unique_eco.py
示例4: plot_zipf
def plot_zipf(*freq):
'''
basic plotting using matplotlib and pylab
'''
ranks, frequencies = [], []
langs, colors = [], []
langs = ["English", "German", "Finnish"]
colors = ['#FF0000', '#00FF00', '#0000FF']
if bonus_part:
colors.extend(['#00FFFF', '#FF00FF', '#FFFF00'])
langs.extend(["English (Stemmed)", "German (Stemmed)", "Finnish (Stemmed)"])
plt.subplot(111) # 1, 1, 1
num = 6 if bonus_part else 3
for i in xrange(num):
ranks.append(range(1, len(freq[i]) + 1))
frequencies.append([e[1] for e in freq[i]])
# log x and y axi, both with base 10
plt.loglog(ranks[i], frequencies[i], marker='', basex=10, color=colors[i], label=langs[i])
plt.legend()
plt.grid(True)
plt.title("Zipf's law!")
plt.xlabel('Rank')
plt.ylabel('Frequency')
plt.show()
开发者ID:mmbrian,项目名称:snlp_ss15,代码行数:30,代码来源:tokenizer.py
示例5: test1
def test1(self):
partition_file = '/home/zy/workspace/viscojapan/tests/share/deformation_partition.h5'
res_file = '/home/zy/workspace/viscojapan/tests/share/nrough_05_naslip_11.h5'
plotter = vj.inv.PredictedTimeSeriesPlotter(
partition_file = partition_file,
#result_file = res_file,
)
site = 'J550'
cmpt = 'e'
#plotter.plot_cumu_disp_pred(site, cmpt)
#plotter.plot_cumu_disp_pred_added(site, cmpt, color='blue')
# plotter.plot_post_disp_pred_added(site, cmpt)
#plotter.plot_cumu_obs_linres(site, cmpt)
#plotter.plot_R_co(site, cmpt)
# plotter.plot_post_disp_pred(site, cmpt)
# plotter.plot_post_obs_linres(site, cmpt)
#plotter.plot_E_cumu_slip(site, cmpt)
# plotter.plot_E_aslip(site, cmpt)
#plotter.plot_R_aslip(site, cmpt)
#plt.show()
#plt.close()
#
plotter.plot_cumu_disp_decomposition(site, cmpt)
plt.show()
plt.close()
plotter.plot_post_disp_decomposition(site, cmpt)
plt.show()
plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:35,代码来源:test_plot_predicted_time_series.py
示例6: run
def run(self):
plt.xticks([]), plt.yticks([])
if self.mode == Mode.DISPLAY:
self.animation = matplotlib.animation.FuncAnimation(self.fig, self.time_step, interval=60)
elif self.mode == Mode.ON_KEY_PRESS:
self.fig.canvas.mpl_connect('key_press_event', self.time_step)
else:
print("Creating video! Could need some time to complete!")
ffmpeg_writer = matplotlib.animation.writers['ffmpeg']
metadata = dict(title=self.video_name.split(".")[0], artist='Matplotlib',
comment='')
writer = ffmpeg_writer(fps=15, metadata=metadata)
n_frames = len(self.data)
with writer.saving(self.fig, self.video_name, n_frames):
for i in range(n_frames):
self.time_step()
writer.grab_frame()
if self.mode != Mode.SAVE:
plt.show()
开发者ID:AurelienNioche,项目名称:SpatialEconomy,代码行数:27,代码来源:moves.py
示例7: imshow
def imshow(self, name):
'''
显示灰度图
'''
img = self.buffer2img(name)
plt.imshow(img, cmap='gray')
plt.axis('off')
plt.show()
开发者ID:DataLoaderX,项目名称:datasetsome,代码行数:8,代码来源:dataloader.py
示例8: close
def close(self):
"""Does nothing."""
plt.show()
self.data = []
self.axis = []
self.count = []
self.initial = []
self.scaleList = []
return
开发者ID:MikeJPlatt,项目名称:plotcase-0.1.0,代码行数:9,代码来源:plotcase.py
示例9: plot_post
def plot_post(cfs,ifshow=False,loc=2,
save_fig_path = None, file_type='png'):
for cf in cfs:
plot_cf(cf, color='blue')
plt.legend(loc=loc)
if ifshow:
plt.show()
if save_fig_path is not None:
plt.savefig(join(save_fig_path, '%s_%s.%s'%(cf.SITE, cf.CMPT, file_type)))
plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:10,代码来源:plot_post.py
示例10: plot
def plot(cls, data, msg=""):
x = np.arange(len(data[:]))
plt.plot(x, data[:, 0], c="red", linewidth=2)
plt.plot(x, data[:, 1], c="blue", linewidth=2)
plt.plot(x, data[:, 2], c="green", linewidth=2)
plt.ylim([-0.01, 1.01])
plt.text(0, -0.12, "{}".format(msg))
plt.show()
开发者ID:AurelienNioche,项目名称:EconomicsBasalGanglia,代码行数:11,代码来源:single_shot_and_plot.py
示例11: main
def main():
r = Route('data/libs.csv')
r.draw()
for i in range(10000000):
if not r.simulate():
break
if i % 1000 == 0:
r.draw()
#sleep(0.001)
raw_input("Press Enter to continue...")
plt.show()
开发者ID:YaTypedef,项目名称:simulated_annealing,代码行数:13,代码来源:annealing.py
示例12: plot_smoothed_alpha_comparison
def plot_smoothed_alpha_comparison(self,rmsval,suffix=''):
plt.plot(self.f,self.alpha,'ko',label='data set')
plt.plot(self.f,self.salpha,'c-',lw=2,label='smoothed angle $\phi$')
plt.xlabel('frequency in Hz')
plt.ylabel('angle $\phi$ in coordinates of circle')
plt.legend()
ylims=plt.axes().get_ylim()
plt.yticks((arange(9)-4)*0.5*pi, ['$-2\pi$','$-3\pi/2$','$-\pi$','$-\pi/2$','$0$','$\pi/2$','$\pi$','$3\pi/2$','$2\pi$'])
plt.ylim(ylims)
plt.title('RMS offset from smooth curve: {:.4f}'.format(rmsval))
if self.show: plt.show()
else: plt.savefig(join(self.sdc.plotpath,'salpha','c{}_salpha_on_{}_circle'.format(self.sdc.case,self.ZorY)+self.sdc.suffix+self.sdc.outsuffix+suffix+'.png'), dpi=240)
plt.close()
开发者ID:antiface,项目名称:zycircle,代码行数:13,代码来源:ZYCircle.py
示例13: test1
def test1(self):
partition_file = '/home/zy/workspace/viscojapan/tests/share/deformation_partition.h5'
plotter = vj.inv.PredictedVelocityTimeSeriesPlotter(
partition_file = partition_file
)
site = 'J550'
cmpt = 'e'
plotter.plot_vel_decomposition(site, cmpt)
plt.show()
plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:13,代码来源:test_plot_predicted_velocity_time_series.py
示例14: plot_overview_B
def plot_overview_B(self,suffix='',ansize=8,anspread=0.15,anmode='quarters',datbg=True,datbgsource=None,checkring=False):
self.start_plot()
if datbg: # data background desired
self.plot_bg_data(datbgsource=datbgsource)
#self.plot_data()
self.plot_fitcircle()
if checkring:
self.plot_checkring()
idxlist=self.to_be_annotated(anmode)
self.annotate_data_points(idxlist,ansize,anspread)
self.plot_characteristic_freqs(annotate=True,size=ansize,spread=anspread)
if self.show: plt.show()
else: plt.savefig(join(self.sdc.plotpath,'c{}_fitted_{}_circle'.format(self.sdc.case,self.ZorY)+self.sdc.suffix+self.sdc.outsuffix+suffix+'.png'), dpi=240)
plt.close()
开发者ID:antiface,项目名称:zycircle,代码行数:14,代码来源:ZYCircle.py
示例15: drawAdoptionNetworkMPL
def drawAdoptionNetworkMPL(G, fnum=1, show=False, writeFile=None):
"""Draws the network to matplotlib, coloring the nodes based on adoption.
Looks for the node attribute 'adopted'. If the attribute is True, colors
the node a different color, showing adoption visually. This function assumes
that the node attributes have been pre-populated.
:param networkx.Graph G: Any NetworkX Graph object.
:param int fnum: The matplotlib figure number. Defaults to 1.
:param bool show:
:param str writeFile: A filename/path to save the figure image. If not
specified, no output file is written.
"""
Gclean = G.subgraph([n for n in G.nodes() if n not in nx.isolates(G)])
plt.figure(num=fnum, figsize=(6,6))
# clear figure
plt.clf()
# Blue ('b') node color for adopters, red ('r') for non-adopters.
nodecolors = ['b' if Gclean.node[n]['adopted'] else 'r' \
for n in Gclean.nodes()]
layout = nx.spring_layout(Gclean)
nx.draw_networkx_nodes(Gclean, layout, node_size=80,
nodelist=Gclean.nodes(),
node_color=nodecolors)
nx.draw_networkx_edges(Gclean, layout, alpha=0.5) # width=4
# TODO: Draw labels of Ii values. Maybe vary size of node.
# TODO: Color edges blue based on influences from neighbors
influenceEdges = []
for a in Gclean.nodes():
for n in Gclean.node[a]['influence']:
influenceEdges.append((a,n))
if len(influenceEdges)>0:
nx.draw_networkx_edges(Gclean, layout, alpha=0.5, width=5,
edgelist=influenceEdges,
edge_color=['b']*len(influenceEdges))
#some extra space around figure
plt.xlim(-0.05,1.05)
plt.ylim(-0.05,1.05)
plt.axis('off')
if writeFile != None:
plt.savefig(writeFile)
if show:
plt.show()
开发者ID:offero,项目名称:diffusionsim,代码行数:49,代码来源:graphgen.py
示例16: plot_overview
def plot_overview(self,suffix=''):
x=self.x; y=self.y; r=self.radius; cx,cy=self.center.real,self.center.imag
ax=plt.axes()
plt.scatter(x,y, marker='o', c='b', s=40)
plt.axhline(y=0,color='grey', zorder=-1)
plt.axvline(x=0,color='grey', zorder=-2)
t=linspace(0,2*pi,201)
circx=r*cos(t) + cx
circy=r*sin(t) + cy
plt.plot(circx,circy,'g-')
plt.plot([cx],[cy],'gx',ms=12)
if self.ZorY == 'Z':
philist,flist=[self.phi_a,self.phi_p,self.phi_n],[self.fa,self.fp,self.fn]
elif self.ZorY == 'Y':
philist,flist=[self.phi_m,self.phi_s,self.phi_r],[self.fm,self.fs,self.fr]
for p,f in zip(philist,flist):
if f is not None:
xpos=cx+r*cos(p); ypos=cy+r*sin(p); xos=0.2*(xpos-cx); yos=0.2*(ypos-cy)
plt.plot([0,xpos],[0,ypos],'co-')
ax.annotate('{:.3f} Hz'.format(f), xy=(xpos,ypos), xycoords='data',
xytext=(xpos+xos,ypos+yos), textcoords='data', #textcoords='offset points',
arrowprops=dict(arrowstyle="->", shrinkA=0, shrinkB=10)
)
#plt.xlim(0,0.16)
#plt.ylim(-0.1,0.1)
plt.axis('equal')
if self.ZorY == 'Z':
plt.xlabel(r'resistance $R$ in Ohm'); plt.ylabel(r'reactance $X$ in Ohm')
if self.ZorY == 'Y':
plt.xlabel(r'conductance $G$ in Siemens'); plt.ylabel(r'susceptance $B$ in Siemens')
plt.title("fitting the admittance circle with Powell's method")
tx1='best fit (fmin_powell):\n'
tx1+='center at G+iB = {:.5f} + i*{:.8f}\n'.format(cx,cy)
tx1+='radius = {:.5f}; '.format(r)
tx1+='residue: {:.2e}'.format(self.resid)
txt1=plt.text(-r,cy-1.1*r,tx1,fontsize=8,ha='left',va='top')
txt1.set_bbox(dict(facecolor='gray', alpha=0.25))
idxlist=self.to_be_annotated('triple')
ofs=self.annotation_offsets(idxlist,factor=0.1,xshift=0.15)
for i,j in enumerate(idxlist):
xpos,ypos = x[j],y[j]; xos,yos = ofs[i].real,ofs[i].imag
ax.annotate('{:.1f} Hz'.format(self.f[j]), xy=(xpos,ypos), xycoords='data',
xytext=(xpos+xos,ypos+yos), textcoords='data', #textcoords='offset points',
arrowprops=dict(arrowstyle="->", shrinkA=0, shrinkB=10)
)
if self.show: plt.show()
else: plt.savefig(join(self.sdc.plotpath,'c{}_fitted_{}_circle'.format(self.sdc.case,self.ZorY)+suffix+'.png'), dpi=240)
plt.close()
开发者ID:antiface,项目名称:zycircle,代码行数:48,代码来源:ZYCircle.py
示例17: plot
def plot(*args):
"""
Recibe señales que se desee graficar
Y muestra todas ellas en un mismo gráfico
"""
import numpy as np
from pylab import plt
plotargs = []
for arg in args:
x = np.arange(0, len(arg))
y = np.array([int(i) for i in arg])
plotargs.extend([x, y])
plt.plot(*plotargs)
plt.show()
开发者ID:IIC2233-2016-02,项目名称:Syllabus,代码行数:16,代码来源:ejemplo_wav.py
示例18: my_2D_plot_of_arrays
def my_2D_plot_of_arrays(xa, ya, title, xlabel, ylabel, *add_graphs):
fig = plt.figure()
ax = fig.add_subplot(111)
lines=ax.plot(xa, ya, 'b-o', markersize=2, color="green")
line = lines[0]
line.set_linewidth( 1.5 )
line.set_color( 'green' )
line.set_linestyle( '-' )
line.set_marker('s')
line.set_markerfacecolor('red')
line.set_markeredgecolor( '0.1' )
line.set_markersize( 3 )
## format the ticks
adl = mdates.AutoDateLocator()
ax.xaxis.set_major_locator(adl)
myformatter = MyAutoDateFormatter(adl)
#myformatter = mdates.AutoDateFormatter(adl)
ax.xaxis.set_major_formatter(myformatter)
ax.set_title(title)
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
labels = getp(ax, 'xticklabels')
setp(labels, color='g', fontsize=9, fontname="Verdana" )
labels = getp(ax, 'yticklabels')
setp(labels, color='g', fontsize=9, fontname="Verdana" )
ax.grid(True)
fig.autofmt_xdate(bottom=0.18, rotation=60)
min_y=min(ya)
max_y=max(ya)
if (min_y<0) and (max_y >0):
ax.axhline(0, color='r', lw=4, alpha=0.5)
ax.fill_between(xa, ya, facecolor='red', alpha=0.5, interpolate=True)
#plot additional graphs
if len(add_graphs):
draw_add_2D_plot_of_arrays(add_graphs, ax)
plt.show()
开发者ID:awesla,项目名称:consumption_analysis,代码行数:46,代码来源:graphics.py
示例19: plot_mat
def plot_mat(data):
# Three subplots sharing both x/y axes
f, axarray = plt.subplots(16, sharex=True, sharey=True)
for i, row in enumerate(data):
axarray[i].plot(range(len(row)), row, 'g')
# Fine-tune figure; make subplots close to each other and hide x ticks for
# all but bottom plot.
f.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in f.axes], visible=False)
plt.setp([a.get_yticklabels() for a in f.axes], visible=False)
axarray[0].set_title('10 minute EEG Reading for Patient')
axarray[int(len(axarray) / 2)].set_ylabel('Magnitude')
axarray[-1].set_xlabel('Time')
font = {'family': 'normal',
'weight': 'bold',
'size': 48}
plt.rc('font', **font)
plt.show()
开发者ID:bhillmann,项目名称:gingivere,代码行数:18,代码来源:visualize_time_series.py
示例20: convolve
def convolve(arrays, melBank, genere, filter_idx):
x = []
melBank_time = np.fft.ifft(melBank) #need to transform melBank to time domain
for eachClip in arrays:
result = np.convolve(eachClip, melBank_time)
x.append(result)
plotBeforeAfterFilter(eachClip, melBank, melBank_time, result, genere, filter_idx)
m = np.asmatrix(np.array(x))
fig, ax = plt.subplots()
ax.matshow(m.real) #each element has imaginary part. So just plot real part
plt.axis('equal')
plt.axis('tight')
plt.title(genere)
plt.tight_layout()
# filename = "./figures/convolution/Convolution_"+"Filter"+str(filter_idx)+genere+".png"
# plt.savefig(filename)
plt.show()
开发者ID:GabrielWen,项目名称:MusicClassification,代码行数:18,代码来源:signalScattering.py
注:本文中的pylab.plt.show函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论