1

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?

DavidG
  • 24,279
  • 14
  • 89
  • 82
NorrinRadd
  • 545
  • 6
  • 21
  • I have some problems understanding this issue. You do not have to do anything manually, but it appears that you *want* to do it manually. The solution you link to actually shows you the coordinates. What is the problem of using them? – ImportanceOfBeingErnest Nov 08 '17 at 13:29

1 Answers1

1

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
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • Yes!! But in my case, i have all the Buttons just like they are depicted above except for the Figure options button ? – NorrinRadd Nov 08 '17 at 13:55
  • That's unfortunate. What version of matplotlib are you using? Which backend are you using? Can you show a screenshot? – ImportanceOfBeingErnest Nov 08 '17 at 13:57
  • Matplotlib version 2.0.2. I am on a windows machine and i am not really sure how to figure out which "backend "i am using to be honest. I do not call a matplotlib.use() comment. – NorrinRadd Nov 08 '17 at 14:02
  • [Finding the backend in use](https://stackoverflow.com/questions/3580027/how-do-you-determine-which-backend-is-being-used-by-matplotlib). I really think a screenshot could help. – ImportanceOfBeingErnest Nov 08 '17 at 14:04
  • Here: [Link](http://i65.tinypic.com/314blfn.png) It doesnt show the full pic unfortunately but underneath is only the task bar and on top/side is the end of the plotwindow! – NorrinRadd Nov 08 '17 at 14:07
  • The backend seems to be "TkAgg" – NorrinRadd Nov 08 '17 at 14:21
  • So are you able to use `Qt4Agg` instead? (I updated the answer). – ImportanceOfBeingErnest Nov 08 '17 at 16:10
  • No, the last thing in my script is: `plt.show() print (matplotlib.rcParams['backend'])` which still shows `TkAgg` even if i include `matplotlib.use("Qt4Agg")` . i have also tried Qt5Agg – NorrinRadd Nov 08 '17 at 19:50
  • Those two lines need to be the first two lines of your script. – ImportanceOfBeingErnest Nov 08 '17 at 21:58
  • That solved the problem! Thank you once again! I had to disable the following lines in my code , which i normally use to get the figure to display almost full screen: `thismanager = get_current_fig_manager()` and `thismanager.window.wm_geometry("1920x1022+0+0")` Is there a simiilar workaorund for the Qt4Agg backend? – NorrinRadd Nov 09 '17 at 15:27
  • Hold on, do you want a solution to type in the axis limits in the tk backend or a solution to set the window full size with Qt backend? – ImportanceOfBeingErnest Nov 09 '17 at 15:32
  • It doesn't matter really. It is just annoying to manual make the figure full screen each time. But to me it seems like the QT backend actually looks slightly better when i export to png. so i will likely keep it like this. Thanks for the support!! – NorrinRadd Nov 11 '17 at 14:37
  • To maximize window in QT, use `plt.get_current_fig_manager().window.showMaximized()`. (see [this thread](https://stackoverflow.com/questions/12439588/how-to-maximize-a-plt-show-window-using-python)). If there is a difference between the png images that are saved using tk and qt backend, this should be investigated furthere, since it should not be the case. – ImportanceOfBeingErnest Nov 11 '17 at 19:06