Realization Method of Simultaneous Display of Multiple Graphs in Different Windows of Python

  • 2021-07-10 20:16:53
  • OfStack

The matplotlib package of Python can easily visualize the data. The blogger recently encountered a problem. The blogger wants to show two pictures in two windows at the same time, but the code running result always shows one picture, and the other picture can only be displayed after deleting the current picture. I found some solutions on the Internet, all of which put them in a window, and the two pictures are sub-pictures. After a period of exploration, the blogger finally solved this problem. The following is a brief introduction.

As shown in the following code, first create an figure for each diagram, so that each diagram will be displayed in a separate window; Then add plt. show () to the back after all the diagram codes are written, so that each diagram can be displayed in different windows at the same time.


 #  Draw a diagram 1
 plt.figure()
 plt.plot(y, 'b-', linewidth=2)
 plt.legend()
 plt.grid(True)
 
 
 #  Draw a diagram 2
 plt.figure()
 plt.plot(z, 'b-', linewidth=2)
 plt.legend()
 plt.grid(True)
 plt.draw()

Related articles: