Python pcolor轴及时

时间:2017-10-14 03:48:25

标签: python matplotlib

所以我在每个时间步骤都在绘制pcolor。我的问题是我想设置plt.colorbar()轴。现在,在每个时间步,当我调用plt.colorbar()时,它再次调整。我可以将它设置为颜色条在一个区间内的某个位置,并且该图将相应地跟随它吗?

def plot_contour_TE(self,filename):
        default_cmap='hot'
        print "Starting to Plot Contour Plot TE Solutions....."
        (x1,y1,ex_sol) = self.ex.get_sol()
        ex_interface_func = self.ex.get_phi()

        (x2,y2,ey_sol) = self.ey.get_sol()
        ey_interface_func = self.ey.get_phi()

        (x5,y5,hz_sol) = self.hz.get_sol()
        hz_interface_func = self.hz.get_phi()


        FFMpegWriter = manimation.writers['ffmpeg']
        metadata = dict(title=filename, artist='Matplotlib',
                        comment='Movie support!')
        writer = FFMpegWriter(fps=60, metadata=metadata)


        fig=plt.figure()

        with writer.saving(fig, filename+ ".mp4", 100):


            for i in range(1,len(self.t_list)):
                print "ploting .... t = " + str(self.t_list[i])

                fulltime=self.t_list[i]
                halftime=self.t_list_shift[i-1]

                plt.subplot(131)
                plt.pcolor(x5,y5,hz_sol[i],cmap=default_cmap)
                #plt.contour(x5,y5,hz_interface_func(x5,y5),[1])
                plt.colorbar()

                plt.title(r"$H_z(x,y,t) : t=$" + str(halftime))

                plt.subplot(132)
                plt.pcolor(x1,y1,ex_sol[i],cmap=default_cmap)
                #plt.contour(x1,y1,ey_interface_func(x1,y1),[1])
                plt.colorbar()

                plt.title(r"$E_x(x,y,t) : t=$" + str(fulltime))

                plt.subplot(133)
                plt.pcolor(x2,y2,ey_sol[i],cmap=default_cmap)
                plt.colorbar()

                #plt.contour(x3,y3,ey_interface_func(x3,y3),[1])
                plt.title(r"$E_y(x,y,t) : t=$" + str(fulltime))

                writer.grab_frame()
                plt.clf() 

0 个答案:

没有答案
相关问题