Skip to content

Figure size when saving #2

@avonmoll

Description

@avonmoll

Thanks for this project! Consider the following example, wherein I create three figures and plot something in each. I like to keep an ipython session open where I may run and re-run the script multiple times. Upon re-run, I want my mpldock window to remain in the same arrangement and just have each figure update.

f = plt.figure(1, clear=True)
ax = f.add_subplot()
ax.plot(rand(10))

f = plt.figure(2, clear=True)
ax2 = f.add_subplot()
ax2.plot(rand(10))

f = plt.figure(3, clear=True)
ax3 = f.add_subplot()
ax3.plot(rand(10))

ax2.figure.savefig("test123.pdf")

My matplotlibrc contains figure.figsize : 6, 6, which I really only care about at save time (since my plots generally end up in TeX manuscripts). Upon first run, the figures are created and the mpldock window shows the figures (though not in the specified dimensions) and the resulting test123.pdf is indeed square. The problem: when I re-run, the file test123.pdf assumes the dimensions of the second figure as it appears in mpldock. I don't know if this is an issue with mpldock or if there is a better way to achieve my desired result.

Background: I write and tweak scripts often while performing some kind of analysis. In my mind, mpldock serves as a sort of dashboard where I can rearrange and resize how I like in order to see all of my figures (and even persist the arrangement, which is very nice). However, when it comes time to save, I need the figures to be in their proper dimensions. When using the qt5agg on macos I can resize the figure window however I want and re-run the script without affecting the dimensions of the saved figure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions