From: <md...@us...> - 2007-09-05 15:28:23
|
Revision: 3789 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3789&view=rev Author: mdboom Date: 2007-09-05 08:28:21 -0700 (Wed, 05 Sep 2007) Log Message: ----------- Bugfix #1767997: Zoom to rectangle and home, previous, next buttons The "original" position of the axes was not being saved/restored in the history stack. This patch saves both "original" and "active" position. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-09-05 15:23:29 UTC (rev 3788) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-09-05 15:28:21 UTC (rev 3789) @@ -1446,7 +1446,10 @@ xmin, xmax = a.get_xlim() ymin, ymax = a.get_ylim() lims.append( (xmin, xmax, ymin, ymax) ) - pos.append( tuple( a.get_position() ) ) + # Store both the original and modified positions + pos.append( ( + tuple( a.get_position(True) ), + tuple( a.get_position() ) ) ) self._views.push(lims) self._positions.push(pos) self.set_history_buttons() @@ -1660,7 +1663,9 @@ xmin, xmax, ymin, ymax = lims[i] a.set_xlim((xmin, xmax)) a.set_ylim((ymin, ymax)) - a.set_position( pos[i] ) + # Restore both the original and modified positions + a.set_position( pos[i][0], 'original' ) + a.set_position( pos[i][1], 'active' ) self.draw() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-09 15:58:37
|
Revision: 3931 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3931&view=rev Author: mdboom Date: 2007-10-09 08:58:36 -0700 (Tue, 09 Oct 2007) Log Message: ----------- Raw files should be saved (optionally) with rgba extension, which is what ImageMagick understands. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-10-09 15:58:09 UTC (rev 3930) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-10-09 15:58:36 UTC (rev 3931) @@ -1079,7 +1079,7 @@ 'png': 'Portable Network Graphics', 'ps' : 'Postscript', 'raw': 'Raw RGBA bitmap', - 'rgb': 'Raw RGBA bitmap', + 'rgba': 'Raw RGBA bitmap', 'svg': 'Scalable Vector Graphics', 'svgz': 'Scalable Vector Graphics' } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pki...@us...> - 2007-12-11 17:14:47
|
Revision: 4697 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4697&view=rev Author: pkienzle Date: 2007-12-11 09:14:44 -0800 (Tue, 11 Dec 2007) Log Message: ----------- remove wx specific gui_repaint comment Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-12-10 21:06:59 UTC (rev 4696) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-12-11 17:14:44 UTC (rev 4697) @@ -953,7 +953,6 @@ a.set_facecolor('lightblue') else: self._active[a] = None self.draw_idle() - #self.gui_repaint() def pick(self, mouseevent): if not self.widgetlock.locked(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-25 12:50:30
|
Revision: 5257 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5257&view=rev Author: jdh2358 Date: 2008-05-25 05:50:29 -0700 (Sun, 25 May 2008) Log Message: ----------- experimenting with log toggle Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-05-25 01:30:32 UTC (rev 5256) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-05-25 12:50:29 UTC (rev 5257) @@ -4,7 +4,7 @@ """ from __future__ import division -import os +import os, warnings import numpy as np import matplotlib.cbook as cbook @@ -1201,8 +1201,17 @@ event.inaxes.grid() self.canvas.draw() elif event.key == 'l': - event.inaxes.toggle_log_lineary() - self.canvas.draw() + warnings.warn('log scale toggling under construction') + if 0: + ax = event.inaxes + scale = ax.get_yscale() + if scale=='log': + ax.set_yscale('linear') + ax.figure.canvas.draw() + elif scale=='linear': + ax.set_yscale('log') + ax.figure.canvas.draw() + elif event.key is not None and (event.key.isdigit() and event.key!='0') or event.key=='a': # 'a' enables all axes if event.key!='a': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-06-10 18:38:10
|
Revision: 5464 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5464&view=rev Author: jdh2358 Date: 2008-06-10 11:36:33 -0700 (Tue, 10 Jun 2008) Log Message: ----------- added backend bases api Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-10 18:08:50 UTC (rev 5463) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-10 18:36:33 UTC (rev 5464) @@ -19,6 +19,7 @@ :class:`MouseEvent` store the meta data like keys and buttons pressed, x and y locations in pixel and :class:`~matplotlib.axes.Axes` coordinates. + """ from __future__ import division @@ -38,17 +39,17 @@ The following methods *must* be implemented in the backend: - * draw_path - * draw_image - * draw_text - * get_text_width_height_descent + * :meth:`draw_path` + * :meth:`draw_image` + * :meth:`draw_text` + * :meth:`get_text_width_height_descent` The following methods *should* be implemented in the backend for optimization reasons: - * draw_markers - * draw_path_collection - * draw_quad_mesh + * :meth:`draw_markers` + * :meth:`draw_path_collection` + * :meth:`draw_quad_mesh` """ def __init__(self): self._texmanager = None @@ -81,9 +82,15 @@ that behavior, those vertices should be removed before calling this function. - ``marker_trans`` is an affine transform applied to the marker. - ``trans`` is an affine transform applied to the path. + ``gc`` + the :class:`GraphicsContextBase` instance + ``marker_trans`` + is an affine transform applied to the marker. + + ``trans`` + is an affine transform applied to the path. + This provides a fallback implementation of draw_markers that makes multiple calls to :meth:`draw_path`. Some @@ -271,14 +278,23 @@ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): """ - Draw the :class:`~matplotlib.image.Image` instance into the - current axes; ``x`` is the distance in pixels from the left - hand side of the canvas. ``y`` is the distance from the - origin. That is, if origin is upper, y is the distance from - top. If origin is lower, y is the distance from bottom + Draw the image instance into the current axes; - bbox is a :class:`~matplotlib.transforms.Bbox` instance for clipping, or - None + ``x`` + is the distance in pixels from the left hand side of the canvas. + + ``y`` + the distance from the origin. That is, if origin is + upper, y is the distance from top. If origin is lower, y + is the distance from bottom + + ``im`` + the :class:`matplotlib._image.Image` instance + + ``bbox`` + a :class:`matplotlib.transforms.Bbox` instance for clipping, or + None + """ raise NotImplementedError @@ -294,18 +310,33 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False): """ - Draw the :class:`~matplotlib.text.Text` instance s at ``x``, - ``y`` (display coords) with - :class:`~matplotlib.font_manager.FontProperties` instance - ``prop`` at ``angle`` in degrees, using :class:`GraphicsContextBase` gc + Draw the text instance + ``gc`` + the :class:`GraphicsContextBase` instance + + ``x`` + the x location of the text in display coords + + ``y`` + the y location of the text in display coords + + ``s`` + a :class:`matplotlib.text.Text` instance + + ``prop`` + a :class:`matplotlib.font_manager.FontProperties` instance + + ``angle`` + the rotation angle in degrees + **backend implementers note** When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work - properly), it helps to change the line in text.py + properly), it helps to change the line in text.py:: - if 0: bbox_artist(self, renderer) + if 0: bbox_artist(self, renderer) to if 1, and then the actual bounding box will be blotted along with your text. @@ -326,7 +357,7 @@ def get_texmanager(self): """ - return the :class:matplotlib.texmanager.TexManager` instance + return the :class:`matplotlib.texmanager.TexManager` instance """ if self._texmanager is None: from matplotlib.texmanager import TexManager @@ -350,12 +381,15 @@ def points_to_pixels(self, points): """ Convert points to display units - points - a float or a numpy array of float + + ``points`` + a float or a numpy array of float + return points converted to pixels - You need to override this function (unless your backend doesn't have a - dpi, eg, postscript or svg). - Some imaging systems assume some value for pixels per inch"" + You need to override this function (unless your backend + doesn't have a dpi, eg, postscript or svg). Some imaging + systems assume some value for pixels per inch:: points to pixels = points * pixels_per_inch/72.0 * dpi/72.0 """ @@ -530,6 +564,7 @@ ``dash_list`` specifies the on-off sequence as points. ``(None, None)`` specifies a solid line + """ self._dashes = dash_offset, dash_list @@ -620,6 +655,7 @@ ``renderer`` the :class:`RendererBase` instance for the draw event + """ def __init__(self, name, canvas, renderer): Event.__init__(self, name, canvas) @@ -636,6 +672,7 @@ ``height`` height of the canvas in pixels + """ def __init__(self, name, canvas): Event.__init__(self, name, canvas) @@ -716,9 +753,18 @@ ``button`` button pressed None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events) + ``key`` - the key pressed: None, chr(range(255), shift, win, or control + the key pressed: None, chr(range(255), 'shift', 'win', or 'control' + + Example usage:: + + def on_press(event): + print 'you pressed', event.button, event.xdata, event.ydata + + cid = fig.canvas.mpl_connect('button_press_event', on_press) + """ x = None # x position - pixels from left of canvas y = None # y position - pixels from right of canvas @@ -750,10 +796,25 @@ ``artist`` the :class:`~matplotlib.artist.Artist` picked - extra class dependent attrs -- eg a - :class:`~matplotlib.lines.Line2D` pick may define different extra - attributes than a :class:`~matplotlib.collections.PatchCollection` - pick event + other + extra class dependent attrs -- eg a + :class:`~matplotlib.lines.Line2D` pick may define different + extra attributes than a + :class:`~matplotlib.collections.PatchCollection` pick event + + + Example usage:: + + line, = ax.plot(rand(100), 'o', picker=5) # 5 points tolerance + + def on_pick(event): + thisline = event.artist + xdata, ydata = thisline.get_data() + ind = event.ind + print 'on pick line:', zip(xdata[ind], ydata[ind]) + + cid = fig.canvas.mpl_connect('pick_event', on_pick) + """ def __init__(self, name, canvas, mouseevent, artist, guiEvent=None, **kwargs): Event.__init__(self, name, canvas, guiEvent) @@ -776,7 +837,16 @@ the key pressed: None, chr(range(255), shift, win, or control This interface may change slightly when better support for - modifier keys is included + modifier keys is included. + + + Example usage:: + + def on_key(event): + print 'you pressed', event.key, event.xdata, event.ydata + + cid = fig.canvas.mpl_connect('key_press_event', on_key) + """ def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None): LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) @@ -1001,9 +1071,18 @@ def button_release_event(self, x, y, button, guiEvent=None): """ Backend derived classes should call this function on any mouse - button release. x,y are the canvas coords: 0,0 is lower, left. - button and key are as defined in :class:`MouseEvent` + button release. + ``x`` + the canvas coordinates where 0=left + + ``y`` + the canvas coordinates where 0=bottom + + ``guiEvent`` + the native UI event that generated the mpl event + + This method will be call all functions connected to the 'button_release_event' with a :class:`MouseEvent` instance. @@ -1016,9 +1095,18 @@ def motion_notify_event(self, x, y, guiEvent=None): """ Backend derived classes should call this function on any - motion-notify-event. x,y are the canvas coords: 0,0 is lower, left. - button and key are as defined in MouseEvent + motion-notify-event. + ``x`` + the canvas coordinates where 0=left + + ``y`` + the canvas coordinates where 0=bottom + + ``guiEvent`` + the native UI event that generated the mpl event + + This method will be call all functions connected to the 'motion_notify_event' with a :class:`MouseEvent` instance. @@ -1241,14 +1329,23 @@ - 'resize_event' - 'scroll_event' - For the three events above, if the mouse is over the axes, - the variable event.inaxes will be set to the axes it is over, - and additionally, the variables event.xdata and event.ydata - will be defined. This is the mouse location in data coords. - See :class`MplEvent` + For the location events (button and key press/release), if the + mouse is over the axes, the variable event.inaxes will be set + to the :class:`~matplotlib.axes.Axes` the event occurs is + over, and additionally, the variables ``event.xdata`` and + ``event.ydata`` will be defined. This is the mouse location in + data coords. See :class:`KeyEvent` and:class:`MouseEvent` for more info. return value is a connection id that can be used with - :meth:`mpl_disconnect` + :meth:`mpl_disconnect`. + + Example usage:: + + def on_press(event): + print 'you pressed', event.button, event.xdata, event.ydata + + cid = canvas.mpl_connect('button_press_event', on_press) + """ return self.callbacks.connect(s, func) @@ -1256,11 +1353,18 @@ def mpl_disconnect(self, cid): """ disconnect callback id cid + + Example usage:: + + cid = canvas.mpl_connect('button_press_event', on_press) + #...later + canvas.mpl_disconnect(cid) """ return self.callbacks.disconnect(cid) def flush_events(self): - """ Flush the GUI events for the figure. Implemented only for + """ + Flush the GUI events for the figure. Implemented only for backends with GUIs. """ raise NotImplementedError @@ -1365,28 +1469,33 @@ They must also define - * save_figure - save the current figure + :meth:`save_figure` + save the current figure - * set_cursor - if you want the pointer icon to change + :meth:`set_cursor` + if you want the pointer icon to change - * _init_toolbar - create your toolbar widget + :meth:`_init_toolbar` + create your toolbar widget - * draw_rubberband (optional) : draw the zoom to rect - "rubberband" rectangle + :meth:`draw_rubberband` (optional) + draw the zoom to rect "rubberband" rectangle - * press : (optional) whenever a mouse button is pressed, you'll be - notified with the event + :meth:`press` (optional) + whenever a mouse button is pressed, you'll be + notified with the event - * release : (optional) whenever a mouse button is released, - you'll be notified with the event + :meth:`release` (optional) + whenever a mouse button is released, you'll be notified with the event - * dynamic_update (optional) dynamically update the window while - navigating + :meth:`dynamic_update` ptional) + dynamically update the window while navigating - * set_message (optional) - display message + :meth:`set_message` ptional) + display message - * set_history_buttons (optional) - you can change the history - back / forward buttons to indicate disabled / enabled state. + :meth:`set_history_buttons` (optional) + you can change the history back / forward buttons to indicate disabled / enabled state. That's it, we'll do the rest! """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-06-11 12:24:52
|
Revision: 5468 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5468&view=rev Author: jdh2358 Date: 2008-06-11 05:23:05 -0700 (Wed, 11 Jun 2008) Log Message: ----------- some more backend bases rest fixes Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-11 01:26:29 UTC (rev 5467) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-11 12:23:05 UTC (rev 5468) @@ -631,8 +631,8 @@ class Event: """ A matplotlib event. Attach additional attributes as defined in - :meth:`FigureCanvasBase.connect`. The following attributes are defined and - shown with their default values + :meth:`FigureCanvasBase.mpl_connect`. The following attributes + are defined and shown with their default values ``name`` the event name @@ -655,7 +655,7 @@ """ An event triggered by a draw operation on the canvas - In addition to the :class`Event` attributes, the following event attributes are defined: + In addition to the :class:`Event` attributes, the following event attributes are defined: ``renderer`` the :class:`RendererBase` instance for the draw event @@ -669,7 +669,7 @@ """ An event triggered by a canvas resize - In addition to the :class`Event` attributes, the following event attributes are defined: + In addition to the :class:`Event` attributes, the following event attributes are defined: ``width`` width of the canvas in pixels @@ -689,7 +689,7 @@ The following additional attributes are defined and shown with their default values - In addition to the :class`Event` attributes, the following event attributes are defined: + In addition to the :class:`Event` attributes, the following event attributes are defined: ``x`` x position - pixels from left of canvas @@ -752,7 +752,7 @@ A mouse event ('button_press_event', 'button_release_event', 'scroll_event', 'motion_notify_event'). - In addition to the :class`Event` and :class:`LocationEvent` + In addition to the :class:`Event` and :class:`LocationEvent` attributes, the following attributes are defined: ``button`` @@ -832,9 +832,9 @@ A key event (key press, key release). Attach additional attributes as defined in - :meth:`FigureCanvasBase.connect`. + :meth:`FigureCanvasBase.mpl_connect`. - In addition to the :class`Event` and :class:`LocationEvent` + In addition to the :class:`Event` and :class:`LocationEvent` attributes, the following attributes are defined: ``key`` @@ -1468,38 +1468,40 @@ backends must implement a canvas that handles connections for 'button_press_event' and 'button_release_event'. See - :meth:`FigureCanvasBase.connect` for more information + :meth:`FigureCanvasBase.mpl_connect` for more information They must also define - :meth:`save_figure` - save the current figure + :meth:`save_figure` + save the current figure - :meth:`set_cursor` - if you want the pointer icon to change + :meth:`set_cursor` + if you want the pointer icon to change - :meth:`_init_toolbar` - create your toolbar widget + :meth:`_init_toolbar` + create your toolbar widget - :meth:`draw_rubberband` (optional) - draw the zoom to rect "rubberband" rectangle + :meth:`draw_rubberband` (optional) + draw the zoom to rect "rubberband" rectangle - :meth:`press` (optional) - whenever a mouse button is pressed, you'll be - notified with the event + :meth:`press` (optional) + whenever a mouse button is pressed, you'll be + notified with the event :meth:`release` (optional) - whenever a mouse button is released, you'll be notified with the event + whenever a mouse button is released, you'll be notified with + the event - :meth:`dynamic_update` ptional) - dynamically update the window while navigating + :meth:`dynamic_update` (optional) + dynamically update the window while navigating - :meth:`set_message` ptional) - display message + :meth:`set_message` (optional) + display message - :meth:`set_history_buttons` (optional) - you can change the history back / forward buttons to indicate disabled / enabled state. + :meth:`set_history_buttons` (optional) + you can change the history back / forward buttons to + indicate disabled / enabled state. That's it, we'll do the rest! """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-06-24 18:06:43
|
Revision: 5666 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5666&view=rev Author: jdh2358 Date: 2008-06-24 11:06:22 -0700 (Tue, 24 Jun 2008) Log Message: ----------- removed draft timeout/idle from backend bases; using events instead Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-24 18:05:55 UTC (rev 5665) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-24 18:06:22 UTC (rev 5666) @@ -1330,37 +1330,6 @@ newCanvas = FigureCanvasClass(self.figure) return newCanvas - def mpl_idle_add(self, func, *args, **kwargs): - """ - add func to idle handler. The signature of func is:: - - b = func(canvas, *args, **kwargs) - - The function will continue to be called until func returns - False or a call to ``canvas.mpl_remove_source(func)`` - - use :meth:`mpl_source_remove` to remove func from the idle handler. - """ - raise NotImplementedError('GUI backend must override') - - def mpl_timeout_add(self, millisec, func, *args, **kwargs): - """ - add func to timeout handler; func will be called every - millisec. The signature of func is:: - - The function will continue to be called until func returns - False or a call to ``canvas.mpl_remove_source(func)`` - - use :meth:`mpl_source_remove` to remove func from the timeout handler. - """ - raise NotImplementedError('GUI backend must override') - - def mpl_source_remove(self, func): - """ - remove func from idle or timeout handler - """ - raise NotImplementedError('GUI backend must override') - def mpl_connect(self, s, func): """ Connect event with string *s* to *func*. The signature of *func* is:: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |