[Python] Matplotlib.pyplot: Open new figure environment

Discussão em 'Python' iniciado por Stack, Novembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    In pyplot, when I run plt.plot(x), it seems to internally run the following logic:

    1) If a figure is already open, use that figure, otherwise create a new one.
    2) If an axes in that figure is already open, use that axes, otherwise create a new one.
    3) Plot on that axis.

    I'm wondering how I can force step (1) to open up a new figure the next time some plotting command is called. Something like

    plt.plot(x1)
    with new_figure_environment(): # Ensure that plot commands within this go to new figures
    some_function()
    plt.show()


    If some_function contains:

    def some_function():
    plt.plot(x1)


    Then I want to open up a new figure, but if it does not contain a plot function then I do not.

    Continue reading...

Compartilhe esta Página