当前位置: 首页>>代码示例>>Python>>正文


Python plt.show函数代码示例

本文整理汇总了Python中pylab.plt.show函数的典型用法代码示例。如果您正苦于以下问题:Python show函数的具体用法?Python show怎么用?Python show使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了show函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的pylab.plt.show函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。