How to ask a Figure whether the zoom was manually changed?

Hello,

I have a simple live-update thread (basically calls set_xdata and
set_ydata on all lines with the new data, then calls canvas.draw() on
all figures).

1. I would like to zoom the figure to contain the whole data range after
each update, but ONLY in case the figure zoom was not changed manuallu

One idea was to connect to resize_event and scroll_event of the canvas,
notifying my code that the zoom was change. But in such a case, clicking
"home" will not revert to automatic zooming.

Is there some better way?

2. Is there an event to be notified when the figure window is close by
the user?

Cheers, Vaclav

Well, as far as I can tell, all zooms are manual unless done explicitly through the code (maybe you meant a situation where a window resize triggers a change in the data limits?) Anyway, you might want to look at some of the set_aspect() options. Also, in the latest version (1.0), we have made some changes with respect to autoscaling that might impact the behavior of your program.

As for closing the window, there is the ‘close_event’ that you can connect to to trigger any clean-up code for yourself. Don’t forget to disconnect it, as not doing so can cause minor issues in some backends.

Ben Root

2010/7/6 Václav Šmilauer <eudoxos@…3186…2…>

···

Hello,

I have a simple live-update thread (basically calls set_xdata and

set_ydata on all lines with the new data, then calls canvas.draw() on

all figures).

  1. I would like to zoom the figure to contain the whole data range after

each update, but ONLY in case the figure zoom was not changed manuallu

One idea was to connect to resize_event and scroll_event of the canvas,

notifying my code that the zoom was change. But in such a case, clicking

“home” will not revert to automatic zooming.

Is there some better way?

  1. Is there an event to be notified when the figure window is close by

the user?

Cheers, Vaclav


This SF.net email is sponsored by Sprint

What will you do first with EVO, the first 4G phone?

Visit sprint.com/firsthttp://p.sf.net/sfu/sprint-com-first


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

2010/7/6 Václav Šmilauer <eudoxos@...2092...>:

Hello,

I have a simple live-update thread (basically calls set_xdata and
set_ydata on all lines with the new data, then calls canvas.draw() on
all figures).

1. I would like to zoom the figure to contain the whole data range after
each update, but ONLY in case the figure zoom was not changed manuallu

One idea was to connect to resize_event and scroll_event of the canvas,
notifying my code that the zoom was change. But in such a case, clicking
"home" will not revert to automatic zooming.

Is there some better way?

I'm not sure exactly, but you might be able to do something with the
xlim_change/ylim_changed events:

http://matplotlib.sourceforge.net/examples/event_handling/viewlims.html

2. Is there an event to be notified when the figure window is close by
the user?

As Ben said, there's an close_event you can listen for. Here's an example:

http://matplotlib.sourceforge.net/examples/event_handling/close_event.html

Ryan

···

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma