matplotlib.pyplot.subplots() - how to set the name of the figure?

后端 未结 3 1572
醉酒成梦
醉酒成梦 2021-01-02 03:34

When I create a single plot using the figure()-function of PyPlot, I can set the name of the appearing window using a string as argument:

import matplotlib.p         


        
相关标签:
3条回答
  • 2021-01-02 03:58

    You can also do this:

    f, axarr = plt.subplots(2,2, num = PlotName)
    

    where PlotName is a string and thus you can generate a window name upon instantiation

    0 讨论(0)
  • 2021-01-02 04:03

    Taken from the docs:

    import matplotlib.pyplot as plt
    
    #...
    
    # Just a figure and one subplot
    f, ax = plt.subplots()
    ax.plot(x, y)
    ax.set_title('Simple plot')
    

    And, to change the title of the Window:

    import matplotlib.pyplot as plt 
    fig = plt.figure() 
    fig.canvas.set_window_title('My Window Title') 
    plt.show() 
    
    0 讨论(0)
  • 2021-01-02 04:14

    plt.subplots() passes additional keyword arguments to plt.figure. Therefore, the num keyword will do what you want.

    fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, num='MyName')
    

    You can also set figsize and dpi etc. in this way too (see plt.figure docs).

    0 讨论(0)
提交回复
热议问题