0

So I'm plotting pcolor at each time step. My problem is that I want to set the plt.colorbar() axis. Right now, at every time step, when I call plt.colorbar() it adjusts again. Can I set it somewhere that the color bar is on an interval, and the plot will follow it accordingly?

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() 
Eigenvalue
  • 1,093
  • 1
  • 14
  • 35
  • see [this question](https://stackoverflow.com/questions/13310594/positioning-the-colorbar) – nos Oct 14 '17 at 04:27
  • I'm sure what you're after is doable. It's just that I don't understand what you are actually trying to do. The code above is no [mcve], hence the output is unknown and we do not know how it is now. Then, what does "color bar is on an interval" mean? Equally, what does "plot will follow it" mean? Please provide a [mcve] and clearly explain how your desired output should look like. – ImportanceOfBeingErnest Oct 14 '17 at 12:14

0 Answers0