Search code examples
pythonmatplotlibzoomingmagnification

Specify Height and Width of zoomed Image in Matplotlib after plt.show()


I have a plotting routine and I show the result with

plt.show()

as this is the easiest way for me to see my data. Once I have found and area which I want to look at i want to plot the exact same area again for a different set of data which has the same xy dimensions. The easies way for me would be to see the coordinates of the corners after the zoom or the origin of the zoom and the size in xy direction.

I found this solution . If I understand it correctly I have to manually change the plotting script with the new x y limits for each subsequent plot I want to make.

Is there a possibility to show the limit of the manual zoom in the panel itself and have the possibility to perform and actual input in dedicated fields such that I can recreate this zoom?


Solution

  • Do you mean something like this?

    enter image description here

    This "Figure options" dialog is present in the Qt backend. To use it,

    import matplotlib
    matplotlib.use("Qt4Agg") # or "Qt5Agg" depending on the version