SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S




1
(2)
2
(2)
3
(2)
4
5
(2)
6
(4)
7
8
9
10
11
12
13
(1)
14
(2)
15
(3)
16
(7)
17
(1)
18
(1)
19
(3)
20
(16)
21
(3)
22
(4)
23
(2)
24
25
26
(6)
27
(3)
28
(9)
29
(2)
30
(2)

Showing 16 results of 16

From: <ry...@us...> - 2010年04月20日 22:37:08
Revision: 8260
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8260&view=rev
Author: ryanmay
Date: 2010年04月20日 22:37:01 +0000 (2010年4月20日)
Log Message:
-----------
Update timer support to allow for kwargs on callbacks. Also fix up a few bugs in the TkAgg implementation.
Modified Paths:
--------------
 trunk/matplotlib/examples/event_handling/timers.py
 trunk/matplotlib/lib/matplotlib/backend_bases.py
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
 trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
 trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py
 trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/examples/event_handling/timers.py
===================================================================
--- trunk/matplotlib/examples/event_handling/timers.py	2010年04月20日 20:23:00 UTC (rev 8259)
+++ trunk/matplotlib/examples/event_handling/timers.py	2010年04月20日 22:37:01 UTC (rev 8260)
@@ -16,8 +16,7 @@
 
 # Create a new timer object. Set the interval 500 milliseconds (1000 is default)
 # and tell the timer what function should be called.
-timer = fig.canvas.new_timer()
-timer.interval = 100
+timer = fig.canvas.new_timer(interval=100)
 timer.add_callback(update_title, ax)
 timer.start()
 
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年04月20日 20:23:00 UTC (rev 8259)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年04月20日 22:37:01 UTC (rev 8260)
@@ -893,11 +893,19 @@
 upon timer events. This list can be manipulated directly, or the
 functions add_callback and remove_callback can be used.
 '''
- def __init__(self):
- #Initialize empty callbacks list and setup default settings
- self.callbacks = []
+ def __init__(self, interval=None, callbacks=None):
+ #Initialize empty callbacks list and setup default settings if necssary
+ if callbacks is None:
+ self.callbacks = []
+ else:
+ self.callbacks = callbacks[:] # Create a copy
+
+ if interval is None:
+ self._interval = 1000
+ else:
+ self._interval = interval
+
 self._single = False
- self._interval = 1000
 
 # Default attribute for holding the GUI-specific timer object
 self._timer = None
@@ -949,21 +957,21 @@
 
 single_shot = property(_get_single_shot, _set_single_shot)
 
- def add_callback(self, func, *args):
+ def add_callback(self, func, *args, **kwargs):
 '''
 Register `func` to be called by timer when the event fires. Any
 additional arguments provided will be passed to `func`.
 '''
- self.callbacks.append((func, args))
+ self.callbacks.append((func, args, kwargs))
 
- def remove_callback(self, func, *args):
+ def remove_callback(self, func, *args, **kwargs):
 '''
- Remove `func` from list of callbacks. `args` is optional and used
- to distinguish between copies of the same function registered to be
- called with different arguments.
+ Remove `func` from list of callbacks. `args` and `kwargs` are optional
+ and used to distinguish between copies of the same function registered
+ to be called with different arguments.
 '''
- if args:
- self.callbacks.remove((func, args))
+ if args or kwargs:
+ self.callbacks.remove((func, args, kwargs))
 else:
 funcs = [c[0] for c in self.callbacks]
 if func in funcs:
@@ -983,10 +991,10 @@
 can return False if they should not be called any more. If there
 are no callbacks, the timer is automatically stopped.
 '''
- for func,args in self.callbacks:
- ret = func(*args)
+ for func,args,kwargs in self.callbacks:
+ ret = func(*args, **kwargs)
 if ret == False:
- self.callbacks.remove((func,args))
+ self.callbacks.remove((func,args,kwargs))
 
 if len(self.callbacks) == 0:
 self.stop()
@@ -1929,13 +1937,21 @@
 """
 return self.callbacks.disconnect(cid)
 
- def new_timer(self):
+ def new_timer(self, *args, **kwargs):
 """
 Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
 This is useful for getting periodic events through the backend's native
 event loop. Implemented only for backends with GUIs.
+ 
+ optional arguments:
+ 
+ *interval*
+ Timer interval in milliseconds
+ *callbacks*
+ Sequence of (func, args, kwargs) where func(*args, **kwargs) will
+ be executed by the timer every *interval*.
 """
- return TimerBase()
+ return TimerBase(*args, **kwargs)
 
 def flush_events(self):
 """
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 20:23:00 UTC (rev 8259)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 22:37:01 UTC (rev 8260)
@@ -448,13 +448,21 @@
 def get_default_filetype(self):
 return 'png'
 
- def new_timer(self):
+ def new_timer(self, *args, **kwargs):
 """
- Creates a new backend-specific subclass of
- :class:`backend_bases.TimerBase`. This is useful for getting periodic
- events through the backend's native event loop.
+ Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
+ This is useful for getting periodic events through the backend's native
+ event loop. Implemented only for backends with GUIs.
+ 
+ optional arguments:
+ 
+ *interval*
+ Timer interval in milliseconds
+ *callbacks*
+ Sequence of (func, args, kwargs) where func(*args, **kwargs) will
+ be executed by the timer every *interval*.
 """
- return TimerGTK()
+ return TimerGTK(*args, **kwargs)
 
 def flush_events(self):
 gtk.gdk.threads_enter()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py	2010年04月20日 20:23:00 UTC (rev 8259)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py	2010年04月20日 22:37:01 UTC (rev 8260)
@@ -97,8 +97,8 @@
 upon timer events. This list can be manipulated directly, or the
 functions add_callback and remove_callback can be used.
 '''
- def __init__(self):
- TimerBase.__init__(self)
+ def __init__(self, *args, **kwargs):
+ TimerBase.__init__(self, *args, **kwargs)
 
 # Create a new timer and connect the timeout() signal to the
 # _on_timer method.
@@ -232,13 +232,21 @@
 
 return key
 
- def new_timer(self):
+ def new_timer(self, *args, **kwargs):
 """
- Creates a new backend-specific subclass of
- :class:`backend_bases.TimerBase`. This is useful for getting periodic
- events through the backend's native event loop.
+ Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
+ This is useful for getting periodic events through the backend's native
+ event loop. Implemented only for backends with GUIs.
+ 
+ optional arguments:
+ 
+ *interval*
+ Timer interval in milliseconds
+ *callbacks*
+ Sequence of (func, args, kwargs) where func(*args, **kwargs) will
+ be executed by the timer every *interval*.
 """
- return TimerQT()
+ return TimerQT(*args, **kwargs)
 
 def flush_events(self):
 Qt.qApp.processEvents()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py	2010年04月20日 20:23:00 UTC (rev 8259)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py	2010年04月20日 22:37:01 UTC (rev 8260)
@@ -108,8 +108,8 @@
 upon timer events. This list can be manipulated directly, or the
 functions add_callback and remove_callback can be used.
 '''
- def __init__(self, parent):
- TimerBase.__init__(self)
+ def __init__(self, parent, *args, **kwargs):
+ TimerBase.__init__(self, *args, **kwargs)
 self.parent = parent
 
 def _timer_start(self):
@@ -126,7 +126,7 @@
 # Tk after() is only a single shot, so we need to add code here to
 # reset the timer if we're not operating in single shot mode.
 if not self._single and len(self.callbacks) > 0:
- self._timer = self.parent.after(self._interval, _self._on_timer)
+ self._timer = self.parent.after(self._interval, self._on_timer)
 else:
 self._timer = None
 
@@ -358,13 +358,21 @@
 key = self._get_key(event)
 FigureCanvasBase.key_release_event(self, key, guiEvent=event)
 
- def new_timer(self):
+ def new_timer(self, *args, **kwargs):
 """
- Creates a new backend-specific subclass of
- :class:`backend_bases.TimerBase`. This is useful for getting periodic
- events through the backend's native event loop.
+ Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
+ This is useful for getting periodic events through the backend's native
+ event loop. Implemented only for backends with GUIs.
+ 
+ optional arguments:
+ 
+ *interval*
+ Timer interval in milliseconds
+ *callbacks*
+ Sequence of (func, args, kwargs) where func(*args, **kwargs) will
+ be executed by the timer every *interval*.
 """
- return TimerTk()
+ return TimerTk(self._tkcanvas, *args, **kwargs)
 
 def flush_events(self):
 self._master.update()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年04月20日 20:23:00 UTC (rev 8259)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年04月20日 22:37:01 UTC (rev 8260)
@@ -240,8 +240,8 @@
 upon timer events. This list can be manipulated directly, or the
 functions add_callback and remove_callback can be used.
 '''
- def __init__(self, parent):
- TimerBase.__init__(self)
+ def __init__(self, parent, *args, **kwargs):
+ TimerBase.__init__(self, *args, **kwargs)
 
 # Create a new timer and connect the timer event to our handler.
 # For WX, the events have to use a widget for binding.
@@ -1022,13 +1022,21 @@
 self._isDrawn = True
 self.gui_repaint(drawDC=drawDC)
 
- def new_timer(self):
+ def new_timer(self, *args, **kwargs):
 """
- Creates a new backend-specific subclass of
- :class:`backend_bases.TimerBase`. This is useful for getting periodic
- events through the backend's native event loop.
+ Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
+ This is useful for getting periodic events through the backend's native
+ event loop. Implemented only for backends with GUIs.
+ 
+ optional arguments:
+ 
+ *interval*
+ Timer interval in milliseconds
+ *callbacks*
+ Sequence of (func, args, kwargs) where func(*args, **kwargs) will
+ be executed by the timer every *interval*.
 """
- return TimerWx(self)
+ return TimerWx(self, *args, **kwargs)
 
 def flush_events(self):
 wx.Yield()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ry...@us...> - 2010年04月20日 20:23:06
Revision: 8259
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8259&view=rev
Author: ryanmay
Date: 2010年04月20日 20:23:00 +0000 (2010年4月20日)
Log Message:
-----------
Add example using new generic timer support and update ChangeLog.
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
Added Paths:
-----------
 trunk/matplotlib/examples/event_handling/timers.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2010年04月20日 20:02:38 UTC (rev 8258)
+++ trunk/matplotlib/CHANGELOG	2010年04月20日 20:23:00 UTC (rev 8259)
@@ -1,3 +1,8 @@
+2010年04月20日 Added generic support for connecting to a timer for events. This
+ adds TimerBase, TimerGTK, TimerQT, TimerWx, and TimerTk to
+ the backends and a new_timer() method to each backend's
+ canvas to allow ease of creating a new timer. - RM
+
 2010年04月20日 Added margins() Axes method and pyplot function. - EF
 
 2010年04月18日 update the axes_grid documentation. -JJL
Added: trunk/matplotlib/examples/event_handling/timers.py
===================================================================
--- trunk/matplotlib/examples/event_handling/timers.py	 (rev 0)
+++ trunk/matplotlib/examples/event_handling/timers.py	2010年04月20日 20:23:00 UTC (rev 8259)
@@ -0,0 +1,30 @@
+# Simple example of using general timer objects. This is used to update
+# the time placed in the title of the figure.
+import matplotlib.pyplot as plt
+import numpy as np
+from datetime import datetime
+
+def update_title(axes):
+ axes.set_title(datetime.now())
+ axes.figure.canvas.draw()
+
+fig = plt.figure()
+ax = fig.add_subplot(1, 1, 1)
+
+x = np.linspace(-3, 3)
+ax.plot(x, x*x)
+
+# Create a new timer object. Set the interval 500 milliseconds (1000 is default)
+# and tell the timer what function should be called.
+timer = fig.canvas.new_timer()
+timer.interval = 100
+timer.add_callback(update_title, ax)
+timer.start()
+
+#Or could start the timer on first figure draw
+#def start_timer(evt):
+# timer.start()
+# fig.canvas.mpl_disconnect(drawid)
+#drawid = fig.canvas.mpl_connect('draw_event', start_timer)
+
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8258
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8258&view=rev
Author: ryanmay
Date: 2010年04月20日 20:02:38 +0000 (2010年4月20日)
Log Message:
-----------
Fix dumb bug in timer calling callbacks with args.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backend_bases.py
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年04月20日 20:01:28 UTC (rev 8257)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年04月20日 20:02:38 UTC (rev 8258)
@@ -984,7 +984,7 @@
 are no callbacks, the timer is automatically stopped.
 '''
 for func,args in self.callbacks:
- ret = func(args)
+ ret = func(*args)
 if ret == False:
 self.callbacks.remove((func,args))
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8257
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8257&view=rev
Author: ryanmay
Date: 2010年04月20日 20:01:28 +0000 (2010年4月20日)
Log Message:
-----------
Remove imports from earlier development.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 19:59:23 UTC (rev 8256)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 20:01:28 UTC (rev 8257)
@@ -103,14 +103,12 @@
 upon timer events. This list can be manipulated directly, or the
 functions add_callback and remove_callback can be used.
 '''
- from gobject import timeout_add as _add_timeout
- from gobject import source_remove as _remove_timeout
 def _timer_start(self):
- self._timer = self._add_timeout(self._interval, self._on_timer)
+ self._timer = gobject.timeout_add(self._interval, self._on_timer)
 
 def _timer_stop(self):
 if self._timer is not None:
- self._remove_timeout(self._timer)
+ gobject.source_remove(self._timer)
 self._timer = None
 
 def _timer_set_interval(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8256
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8256&view=rev
Author: ryanmay
Date: 2010年04月20日 19:59:23 +0000 (2010年4月20日)
Log Message:
-----------
Remove extra import in timer.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年04月20日 19:58:10 UTC (rev 8255)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年04月20日 19:59:23 UTC (rev 8256)
@@ -241,7 +241,6 @@
 functions add_callback and remove_callback can be used.
 '''
 def __init__(self, parent):
- import wx
 TimerBase.__init__(self)
 
 # Create a new timer and connect the timer event to our handler.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8255
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8255&view=rev
Author: ryanmay
Date: 2010年04月20日 19:58:10 +0000 (2010年4月20日)
Log Message:
-----------
Use global import of PyQt4 instead of a local one.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py	2010年04月20日 19:43:01 UTC (rev 8254)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py	2010年04月20日 19:58:10 UTC (rev 8255)
@@ -98,18 +98,19 @@
 functions add_callback and remove_callback can be used.
 '''
 def __init__(self):
- from PyQt4.QtCore import QObject, SIGNAL, QTimer
 TimerBase.__init__(self)
 
 # Create a new timer and connect the timeout() signal to the
 # _on_timer method.
- self._timer = QTimer()
- QObject.connect(self._timer, SIGNAL('timeout()'), self._on_timer)
+ self._timer = QtCore.QTimer()
+ QtCore.QObject.connect(self._timer, QtCore.SIGNAL('timeout()'),
+ self._on_timer)
 
 def __del__(self):
 # Probably not necessary in practice, but is good behavior to disconnect
 TimerBase.__del__(self)
- QObject.disconnect(self._timer , SIGNAL('timeout()'), self._on_timer)
+ QtCore.QObject.disconnect(self._timer , QtCore.SIGNAL('timeout()'),
+ self._on_timer)
 
 def _timer_set_single_shot(self):
 self._timer.setSingleShot(self._single)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8254
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8254&view=rev
Author: ryanmay
Date: 2010年04月20日 19:43:01 +0000 (2010年4月20日)
Log Message:
-----------
Add TimerTk and new_timer() method.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py	2010年04月20日 19:42:29 UTC (rev 8253)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py	2010年04月20日 19:43:01 UTC (rev 8254)
@@ -13,7 +13,7 @@
 import matplotlib
 from matplotlib.cbook import is_string_like
 from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
- FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors
+ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors, TimerBase
 
 from matplotlib.figure import Figure
 from matplotlib._pylab_helpers import Gcf
@@ -95,6 +95,42 @@
 return figManager
 
 
+class TimerTk(TimerBase):
+ '''
+ Subclass of :class:`backend_bases.TimerBase` that uses Tk's timer events.
+ 
+ Attributes:
+ * interval: The time between timer events in milliseconds. Default
+ is 1000 ms.
+ * single_shot: Boolean flag indicating whether this timer should
+ operate as single shot (run once and then stop). Defaults to False.
+ * callbacks: Stores list of (func, args) tuples that will be called
+ upon timer events. This list can be manipulated directly, or the
+ functions add_callback and remove_callback can be used.
+ '''
+ def __init__(self, parent):
+ TimerBase.__init__(self)
+ self.parent = parent
+
+ def _timer_start(self):
+ self._timer = self.parent.after(self._interval, self._on_timer)
+
+ def _timer_stop(self):
+ if self._timer is not None:
+ self.parent.after_cancel(self._timer)
+ self._timer = None
+
+ def _on_timer(self):
+ TimerBase._on_timer(self)
+
+ # Tk after() is only a single shot, so we need to add code here to
+ # reset the timer if we're not operating in single shot mode.
+ if not self._single and len(self.callbacks) > 0:
+ self._timer = self.parent.after(self._interval, _self._on_timer)
+ else:
+ self._timer = None
+
+
 class FigureCanvasTkAgg(FigureCanvasAgg):
 keyvald = {65507 : 'control',
 65505 : 'shift',
@@ -322,6 +358,14 @@
 key = self._get_key(event)
 FigureCanvasBase.key_release_event(self, key, guiEvent=event)
 
+ def new_timer(self):
+ """
+ Creates a new backend-specific subclass of
+ :class:`backend_bases.TimerBase`. This is useful for getting periodic
+ events through the backend's native event loop.
+ """
+ return TimerTk()
+
 def flush_events(self):
 self._master.update()
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8253
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8253&view=rev
Author: ryanmay
Date: 2010年04月20日 19:42:29 +0000 (2010年4月20日)
Log Message:
-----------
Add TimerWx and new_timer() method.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年04月20日 19:42:05 UTC (rev 8252)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年04月20日 19:42:29 UTC (rev 8253)
@@ -190,7 +190,7 @@
 from matplotlib import verbose
 from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
 FigureCanvasBase, FigureManagerBase, NavigationToolbar2, \
- cursors
+ cursors, TimerBase
 from matplotlib._pylab_helpers import Gcf
 from matplotlib.artist import Artist
 from matplotlib.cbook import exception_to_str, is_string_like, is_writable_file_like
@@ -226,6 +226,52 @@
 msg = '\n'.join(map(str, msg))
 return msg
 
+
+class TimerWx(TimerBase):
+ '''
+ Subclass of :class:`backend_bases.TimerBase` that uses WxTimer events.
+ 
+ Attributes:
+ * interval: The time between timer events in milliseconds. Default
+ is 1000 ms.
+ * single_shot: Boolean flag indicating whether this timer should
+ operate as single shot (run once and then stop). Defaults to False.
+ * callbacks: Stores list of (func, args) tuples that will be called
+ upon timer events. This list can be manipulated directly, or the
+ functions add_callback and remove_callback can be used.
+ '''
+ def __init__(self, parent):
+ import wx
+ TimerBase.__init__(self)
+
+ # Create a new timer and connect the timer event to our handler.
+ # For WX, the events have to use a widget for binding.
+ self.parent = parent
+ self._timer = wx.Timer(self.parent, wx.NewId())
+ self.parent.Bind(wx.EVT_TIMER, self._on_timer, self._timer)
+
+ # Unbinding causes Wx to stop for some reason. Disabling for now.
+# def __del__(self):
+# import wx
+# TimerBase.__del__(self)
+# self.parent.Bind(wx.EVT_TIMER, None, self._timer)
+
+ def _timer_start(self):
+ self._timer.Start(self._interval, self._single)
+
+ def _timer_stop(self):
+ self._timer.Stop()
+
+ def _timer_set_interval(self):
+ self._timer_start()
+
+ def _timer_set_single_shot(self):
+ self._timer.start()
+
+ def _on_timer(self, *args):
+ TimerBase._on_timer(self)
+
+
 class RendererWx(RendererBase):
 """
 The renderer handles all the drawing primitives using a graphics
@@ -938,7 +984,6 @@
 printout.Destroy()
 self.gui_repaint()
 
-
 def draw_idle(self):
 """
 Delay rendering until the GUI is idle.
@@ -978,6 +1023,14 @@
 self._isDrawn = True
 self.gui_repaint(drawDC=drawDC)
 
+ def new_timer(self):
+ """
+ Creates a new backend-specific subclass of
+ :class:`backend_bases.TimerBase`. This is useful for getting periodic
+ events through the backend's native event loop.
+ """
+ return TimerWx(self)
+
 def flush_events(self):
 wx.Yield()
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8252
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8252&view=rev
Author: ryanmay
Date: 2010年04月20日 19:42:05 +0000 (2010年4月20日)
Log Message:
-----------
Add TimerQT and new_timer() method.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py	2010年04月20日 19:41:38 UTC (rev 8251)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py	2010年04月20日 19:42:05 UTC (rev 8252)
@@ -7,7 +7,8 @@
 from matplotlib import verbose
 from matplotlib.cbook import is_string_like, onetrue
 from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
- FigureManagerBase, FigureCanvasBase, NavigationToolbar2, IdleEvent, cursors
+ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, IdleEvent, \
+ cursors, TimerBase
 from matplotlib._pylab_helpers import Gcf
 from matplotlib.figure import Figure
 from matplotlib.mathtext import MathTextParser
@@ -83,6 +84,46 @@
 return manager
 
 
+class TimerQT(TimerBase):
+ '''
+ Subclass of :class:`backend_bases.TimerBase` that uses Qt4 timer events.
+ 
+ Attributes:
+ * interval: The time between timer events in milliseconds. Default
+ is 1000 ms.
+ * single_shot: Boolean flag indicating whether this timer should
+ operate as single shot (run once and then stop). Defaults to False.
+ * callbacks: Stores list of (func, args) tuples that will be called
+ upon timer events. This list can be manipulated directly, or the
+ functions add_callback and remove_callback can be used.
+ '''
+ def __init__(self):
+ from PyQt4.QtCore import QObject, SIGNAL, QTimer
+ TimerBase.__init__(self)
+ 
+ # Create a new timer and connect the timeout() signal to the
+ # _on_timer method.
+ self._timer = QTimer()
+ QObject.connect(self._timer, SIGNAL('timeout()'), self._on_timer)
+
+ def __del__(self):
+ # Probably not necessary in practice, but is good behavior to disconnect
+ TimerBase.__del__(self)
+ QObject.disconnect(self._timer , SIGNAL('timeout()'), self._on_timer)
+
+ def _timer_set_single_shot(self):
+ self._timer.setSingleShot(self._single)
+
+ def _timer_set_interval(self):
+ self._timer.setInterval(self._interval)
+
+ def _timer_start(self):
+ self._timer.start()
+
+ def _timer_stop(self):
+ self._timer.stop()
+
+
 class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ):
 keyvald = { QtCore.Qt.Key_Control : 'control',
 QtCore.Qt.Key_Shift : 'shift',
@@ -190,6 +231,14 @@
 
 return key
 
+ def new_timer(self):
+ """
+ Creates a new backend-specific subclass of
+ :class:`backend_bases.TimerBase`. This is useful for getting periodic
+ events through the backend's native event loop.
+ """
+ return TimerQT()
+
 def flush_events(self):
 Qt.qApp.processEvents()
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8251
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8251&view=rev
Author: ryanmay
Date: 2010年04月20日 19:41:38 +0000 (2010年4月20日)
Log Message:
-----------
Add TimerGTK and new_timer() method.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 19:40:12 UTC (rev 8250)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 19:41:38 UTC (rev 8251)
@@ -23,7 +23,7 @@
 from matplotlib import verbose
 from matplotlib._pylab_helpers import Gcf
 from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
- FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors
+ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors, TimerBase
 from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
 from matplotlib.cbook import is_string_like, is_writable_file_like
 from matplotlib.colors import colorConverter
@@ -90,6 +90,46 @@
 return manager
 
 
+class TimerGTK(TimerBase):
+ '''
+ Subclass of :class:`backend_bases.TimerBase` that uses GTK for timer events.
+ 
+ Attributes:
+ * interval: The time between timer events in milliseconds. Default
+ is 1000 ms.
+ * single_shot: Boolean flag indicating whether this timer should
+ operate as single shot (run once and then stop). Defaults to False.
+ * callbacks: Stores list of (func, args) tuples that will be called
+ upon timer events. This list can be manipulated directly, or the
+ functions add_callback and remove_callback can be used.
+ '''
+ from gobject import timeout_add as _add_timeout
+ from gobject import source_remove as _remove_timeout
+ def _timer_start(self):
+ self._timer = self._add_timeout(self._interval, self._on_timer)
+
+ def _timer_stop(self):
+ if self._timer is not None:
+ self._remove_timeout(self._timer)
+ self._timer = None
+
+ def _timer_set_interval(self):
+ if self._timer is not None:
+ self._timer_stop()
+ self._timer_start()
+
+ def _on_timer(self):
+ TimerBase._on_timer(self)
+ 
+ # Gtk timeout_add() requires that the callback returns True if it
+ # is to be called again.
+ if len(self.callbacks) > 0 and not self._single:
+ return True
+ else:
+ self._timer = None
+ return False
+
+
 class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase):
 keyvald = {65507 : 'control',
 65505 : 'shift',
@@ -410,6 +450,13 @@
 def get_default_filetype(self):
 return 'png'
 
+ def new_timer(self):
+ """
+ Creates a new backend-specific subclass of
+ :class:`backend_bases.TimerBase`. This is useful for getting periodic
+ events through the backend's native event loop.
+ """
+ return TimerGTK()
 
 def flush_events(self):
 gtk.gdk.threads_enter()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8250
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8250&view=rev
Author: ryanmay
Date: 2010年04月20日 19:40:12 +0000 (2010年4月20日)
Log Message:
-----------
Add base support and API for creating backend-independant timers, implemented using the GUI toolkit's timer support.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backend_bases.py
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年04月20日 19:01:53 UTC (rev 8249)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年04月20日 19:40:12 UTC (rev 8250)
@@ -861,6 +861,137 @@
 return None
 return Path.hatch(self._hatch, density)
 
+
+class TimerBase(object):
+ '''
+ A base class for providing timer events, useful for things animations.
+ Backends need to implement a few specific methods in order to use their
+ own timing mechanisms so that the timer events are integrated into their
+ event loops.
+ 
+ Mandatory functions that must be implemented:
+ * _timer_start: Contains backend-specific code for starting the timer
+ * _timer_stop: Contains backend-specific code for stopping the timer
+
+ Optional overrides:
+ * _timer_set_single_shot: Code for setting the timer to single shot
+ operating mode, if supported by the timer object. If not, the Timer
+ class itself will store the flag and the _on_timer method should
+ be overridden to support such behavior.
+ * _timer_set_interval: Code for setting the interval on the timer, if
+ there is a method for doing so on the timer object.
+ * _on_timer: This is the internal function that any timer object should
+ call, which will handle the task of running all callbacks that have
+ been set.
+ 
+ Attributes:
+ * interval: The time between timer events in milliseconds. Default
+ is 1000 ms.
+ * single_shot: Boolean flag indicating whether this timer should
+ operate as single shot (run once and then stop). Defaults to False.
+ * callbacks: Stores list of (func, args) tuples that will be called
+ upon timer events. This list can be manipulated directly, or the
+ functions add_callback and remove_callback can be used.
+ '''
+ def __init__(self):
+ #Initialize empty callbacks list and setup default settings
+ self.callbacks = []
+ self._single = False
+ self._interval = 1000
+
+ # Default attribute for holding the GUI-specific timer object
+ self._timer = None
+
+ def __del__(self):
+ 'Need to stop timer and possibly disconnect timer.'
+ self._timer_stop()
+
+ def start(self, interval=None):
+ '''
+ Start the timer object. `interval` is optional and will be used
+ to reset the timer interval first if provided.
+ '''
+ if interval is not None:
+ self.set_interval(interval)
+ self._timer_start()
+
+ def stop(self):
+ '''
+ Stop the timer.
+ '''
+ self._timer_stop()
+
+ def _timer_start(self):
+ #TODO: Could we potentially make a generic version through
+ #the use of Threads?
+ raise NotImplementedError('Needs to be implemented by subclass.')
+
+ def _timer_stop(self):
+ #TODO: Could we potentially make a generic version through
+ #the use of Threads?
+ raise NotImplementedError('Needs to be implemented by subclass.')
+
+ def _get_interval(self):
+ return self._interval
+
+ def _set_interval(self, interval):
+ self._interval = interval
+ self._timer_set_interval()
+
+ interval = property(_get_interval, _set_interval)
+
+ def _get_single_shot(self):
+ return self._single
+
+ def _set_single_shot(self, ss=True):
+ self._single = ss
+ self._timer_set_single_shot()
+
+ single_shot = property(_get_single_shot, _set_single_shot)
+
+ def add_callback(self, func, *args):
+ '''
+ Register `func` to be called by timer when the event fires. Any
+ additional arguments provided will be passed to `func`.
+ '''
+ self.callbacks.append((func, args))
+
+ def remove_callback(self, func, *args):
+ '''
+ Remove `func` from list of callbacks. `args` is optional and used
+ to distinguish between copies of the same function registered to be
+ called with different arguments.
+ '''
+ if args:
+ self.callbacks.remove((func, args))
+ else:
+ funcs = [c[0] for c in self.callbacks]
+ if func in funcs:
+ self.callbacks.pop(funcs.index(func))
+
+ def _timer_set_interval(self):
+ 'Used to set interval on underlying timer object.'
+ pass
+
+ def _timer_set_single_shot(self):
+ 'Used to set single shot on underlying timer object.'
+ pass
+
+ def _on_timer(self):
+ '''
+ Runs all function that have been registered as callbacks. Functions
+ can return False if they should not be called any more. If there
+ are no callbacks, the timer is automatically stopped.
+ '''
+ for func,args in self.callbacks:
+ ret = func(args)
+ if ret == False:
+ self.callbacks.remove((func,args))
+
+ if len(self.callbacks) == 0:
+ self.stop()
+
+
 class Event:
 """
 A matplotlib event. Attach additional attributes as defined in
@@ -1455,7 +1586,6 @@
 event = IdleEvent(s, self, guiEvent=guiEvent)
 self.callbacks.process(s, event)
 
-
 def draw(self, *args, **kwargs):
 """
 Render the :class:`~matplotlib.figure.Figure`
@@ -1799,6 +1929,14 @@
 """
 return self.callbacks.disconnect(cid)
 
+ def new_timer(self):
+ """
+ Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
+ This is useful for getting periodic events through the backend's native
+ event loop. Implemented only for backends with GUIs.
+ """
+ return TimerBase()
+
 def flush_events(self):
 """
 Flush the GUI events for the figure. Implemented only for
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年04月20日 19:02:00
Revision: 8249
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8249&view=rev
Author: efiring
Date: 2010年04月20日 19:01:53 +0000 (2010年4月20日)
Log Message:
-----------
Add margins() method to Axes, function to pyplot
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/boilerplate.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2010年04月20日 17:38:56 UTC (rev 8248)
+++ trunk/matplotlib/CHANGELOG	2010年04月20日 19:01:53 UTC (rev 8249)
@@ -1,3 +1,5 @@
+2010年04月20日 Added margins() Axes method and pyplot function. - EF
+
 2010年04月18日 update the axes_grid documentation. -JJL
 
 2010年04月18日 Control MaxNLocator parameters after instantiation,
Modified: trunk/matplotlib/boilerplate.py
===================================================================
--- trunk/matplotlib/boilerplate.py	2010年04月20日 17:38:56 UTC (rev 8248)
+++ trunk/matplotlib/boilerplate.py	2010年04月20日 19:01:53 UTC (rev 8249)
@@ -103,6 +103,7 @@
 'annotate',
 'ticklabel_format',
 'locator_params',
+ 'margins',
 )
 
 cmappable = {
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2010年04月20日 17:38:56 UTC (rev 8248)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2010年04月20日 19:01:53 UTC (rev 8249)
@@ -836,6 +836,8 @@
 
 self._autoscaleXon = True
 self._autoscaleYon = True
+ self._xmargin = 0
+ self._ymargin = 0
 self._update_transScale() # needed?
 
 self._get_lines = _process_plot_var_args(self)
@@ -1605,6 +1607,83 @@
 """
 self._autoscaleYon = b
 
+ def set_xmargin(self, m):
+ """
+ Set padding of X data limits prior to autoscaling.
+
+ *m* times the data interval will be added to each
+ end of that interval before it is used in autoscaling.
+
+ accepts: float in range 0 to 1
+ """
+ if m < 0 or m > 1:
+ raise ValueError("margin must be in range 0 to 1")
+ self._xmargin = m
+
+ def set_ymargin(self, m):
+ """
+ Set padding of Y data limits prior to autoscaling.
+
+ *m* times the data interval will be added to each
+ end of that interval before it is used in autoscaling.
+
+ accepts: float in range 0 to 1
+ """
+ if m < 0 or m > 1:
+ raise ValueError("margin must be in range 0 to 1")
+ self._ymargin = m
+
+
+ def margins(self, *args, **kw):
+ """
+ Convenience method to set or retrieve autoscaling margins.
+
+ signatures::
+
+ margins()
+
+ returns xmargin, ymargin
+
+ ::
+
+ margins(margin, tight=True)
+
+ margins(xmargin, ymargin, tight=True)
+
+ margins(x=xmargin, y=ymargin, tight=True)
+
+ All three forms above set the xmargin and ymargin parameters.
+ All keyword parameters are optional. A single argument
+ specifies both xmargin and ymargin. The *tight* parameter
+ is passed to :meth:`autoscale_view`, which is executed after
+ a margin is changed.
+
+ Specifying any margin changes only the autoscaling; for example,
+ if *xmargin* is not zero, then *xmargin* times the X data
+ interval will be added to each end of that interval before
+ it is used in autoscaling.
+
+ """
+ if not args and not kw:
+ return self._ymargin, self._ymargin
+
+ tight = kw.pop('tight', False)
+ mx = kw.pop('x', None)
+ my = kw.pop('y', None)
+ if len(args) == 1:
+ mx = my = args[0]
+ elif len(args) == 2:
+ mx, my = args
+ else:
+ raise ValueError("more than two arguments were supplied")
+ if mx is not None:
+ self.set_xmargin(mx)
+ if my is not None:
+ self.set_ymargin(my)
+
+ self.autoscale_view(tight=tight, scalex=bool(mx), scaley=bool(my))
+
+
 def set_rasterization_zorder(self, z):
 """
 Set zorder value below which artists will be rasterized
@@ -1631,11 +1710,21 @@
 dl = [ax.dataLim for ax in xshared]
 bb = mtransforms.BboxBase.union(dl)
 x0, x1 = bb.intervalx
+ if self._xmargin > 0:
+ delta = (x1 - x0) * self._xmargin
+ x0 -= delta
+ x1 += delta
+
 if scaley and self._autoscaleYon:
 yshared = self._shared_y_axes.get_siblings(self)
 dl = [ax.dataLim for ax in yshared]
 bb = mtransforms.BboxBase.union(dl)
 y0, y1 = bb.intervaly
+ if self._ymargin > 0:
+ delta = (y1 - y0) * self._ymargin
+ y0 -= delta
+ y1 += delta
+
 if (tight or (len(self.images)>0 and
 len(self.lines)==0 and
 len(self.patches)==0)):
@@ -1958,7 +2047,7 @@
 of ticks and use tight bounds when plotting small
 subplots, for example::
 
- ax.set_locator_params(tight=True, nbins=4)
+ ax.locator_params(tight=True, nbins=4)
 
 Because the locator is involved in autoscaling,
 :meth:`autoscale_view` is called automatically after
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2010年04月20日 17:38:56 UTC (rev 8248)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2010年04月20日 19:01:53 UTC (rev 8249)
@@ -2545,6 +2545,14 @@
 
 # This function was autogenerated by boilerplate.py. Do not edit as
 # changes will be lost
+...@do...py_dedent(Axes.margins)
+def margins(*args, **kw):
+ ret = gca().margins(*args, **kw)
+ draw_if_interactive()
+ return ret
+
+# This function was autogenerated by boilerplate.py. Do not edit as
+# changes will be lost
 def autumn():
 '''
 set the default colormap to autumn and apply to current image if any.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8248
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8248&view=rev
Author: leejjoon
Date: 2010年04月20日 17:38:56 +0000 (2010年4月20日)
Log Message:
-----------
fix axisartist.grid_finder.py to account for the api change of MaxNLocator
Modified Paths:
--------------
 trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py
Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py	2010年04月20日 16:44:01 UTC (rev 8247)
+++ trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py	2010年04月20日 17:38:56 UTC (rev 8248)
@@ -256,8 +256,9 @@
 symmetric=False,
 prune=None):
 
- mticker.MaxNLocator.__init__(self, nbins, steps,
- trim, integer, symmetric, prune)
+ mticker.MaxNLocator.__init__(self, nbins, steps=steps,
+ trim=trim, integer=integer,
+ symmetric=symmetric, prune=prune)
 self.create_dummy_axis()
 
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <lee...@us...> - 2010年04月20日 16:44:08
Revision: 8247
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8247&view=rev
Author: leejjoon
Date: 2010年04月20日 16:44:01 +0000 (2010年4月20日)
Log Message:
-----------
update axes_grid toolkit documentation
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step01.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step02.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step03.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step04.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_axis_direction.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_ticklabel_alignment.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/parasite_simple.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_direction01.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_direction03.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_pad.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_rgb.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/index.rst
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/index.rst
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst
 trunk/matplotlib/examples/axes_grid/demo_curvelinear_grid.py
 trunk/matplotlib/examples/axes_grid/demo_parasite_axes2.py
 trunk/matplotlib/examples/axes_grid/scatter_hist.py
 trunk/matplotlib/examples/axes_grid/simple_axisline4.py
Added Paths:
-----------
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_colorbar.py
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axisartist.rst
Removed Paths:
-------------
 trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/CHANGELOG	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,3 +1,5 @@
+2010年04月18日 update the axes_grid documentation. -JJL
+
 2010年04月18日 Control MaxNLocator parameters after instantiation,
 and via Axes.locator_params method, with corresponding
 pyplot function. -EF
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step01.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step01.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step01.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,8 +1,8 @@
 import matplotlib.pyplot as plt
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
 def setup_axes(fig, rect):
- ax = axislines.Subplot(fig, rect)
+ ax = axisartist.Subplot(fig, rect)
 fig.add_axes(ax)
 
 ax.set_ylim(-0.1, 1.5)
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step02.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step02.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step02.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,8 +1,8 @@
 import matplotlib.pyplot as plt
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
 def setup_axes(fig, rect):
- ax = axislines.Subplot(fig, rect)
+ ax = axisartist.Subplot(fig, rect)
 fig.add_axes(ax)
 
 ax.set_ylim(-0.1, 1.5)
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step03.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step03.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step03.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,8 +1,8 @@
 import matplotlib.pyplot as plt
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
 def setup_axes(fig, rect):
- ax = axislines.Subplot(fig, rect)
+ ax = axisartist.Subplot(fig, rect)
 fig.add_axes(ax)
 
 ax.set_ylim(-0.1, 1.5)
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step04.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step04.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/axis_direction_demo_step04.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,8 +1,8 @@
 import matplotlib.pyplot as plt
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
 def setup_axes(fig, rect):
- ax = axislines.Subplot(fig, rect)
+ ax = axisartist.Subplot(fig, rect)
 fig.add_axes(ax)
 
 ax.set_ylim(-0.1, 1.5)
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_axis_direction.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_axis_direction.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_axis_direction.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,14 +1,14 @@
 
 
 import numpy as np
-import mpl_toolkits.axes_grid.angle_helper as angle_helper
-import mpl_toolkits.axes_grid.grid_finder as grid_finder
+import mpl_toolkits.axisartist.angle_helper as angle_helper
+import mpl_toolkits.axisartist.grid_finder as grid_finder
 from matplotlib.projections import PolarAxes
 from matplotlib.transforms import Affine2D
 
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
-from mpl_toolkits.axes_grid.grid_helper_curvelinear import GridHelperCurveLinear
+from mpl_toolkits.axisartist.grid_helper_curvelinear import GridHelperCurveLinear
 
 
 def setup_axes(fig, rect):
@@ -39,7 +39,7 @@
 )
 
 
- ax1 = axislines.Subplot(fig, rect, grid_helper=grid_helper)
+ ax1 = axisartist.Subplot(fig, rect, grid_helper=grid_helper)
 ax1.axis[:].toggle(ticklabels=False)
 
 fig.add_subplot(ax1)
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_ticklabel_alignment.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_ticklabel_alignment.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_ticklabel_alignment.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,12 +1,12 @@
 
 
 import matplotlib.pyplot as plt
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
 
 def setup_axes(fig, rect):
 
- ax = axislines.Subplot(fig, rect)
+ ax = axisartist.Subplot(fig, rect)
 fig.add_subplot(ax)
 
 ax.set_yticks([0.2, 0.8])
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/parasite_simple.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/parasite_simple.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/parasite_simple.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,11 +1,8 @@
-from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
+from mpl_toolkits.axes_grid1 import host_subplot
 import matplotlib.pyplot as plt
 
-fig = plt.figure(1)
+host = host_subplot(111)
 
-host = SubplotHost(fig, 111)
-fig.add_subplot(host)
-
 par = host.twinx()
 
 host.set_xlabel("Distance")
@@ -15,10 +12,13 @@
 p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density")
 p2, = par.plot([0, 1, 2], [0, 3, 2], label="Temperature")
 
-host.axis["left"].label.set_color(p1.get_color())
-par.axis["right"].label.set_color(p2.get_color())
+leg = plt.legend()
 
-host.legend()
+host.yaxis.get_label().set_color(p1.get_color())
+leg.texts[0].set_color(p1.get_color())
 
+par.yaxis.get_label().set_color(p2.get_color())
+leg.texts[1].set_color(p2.get_color())
+
 plt.show()
 
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_direction01.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_direction01.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_direction01.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,8 +1,8 @@
 import matplotlib.pyplot as plt
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
 fig = plt.figure(figsize=(4,2.5))
-ax1 = fig.add_subplot(axislines.Subplot(fig, "111"))
+ax1 = fig.add_subplot(axisartist.Subplot(fig, "111"))
 fig.subplots_adjust(right=0.8)
 
 ax1.axis["left"].major_ticklabels.set_axis_direction("top")
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_direction03.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_direction03.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_direction03.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,9 +1,9 @@
 
 import matplotlib.pyplot as plt
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
 def setup_axes(fig, rect):
- ax = axislines.Subplot(fig, rect)
+ ax = axisartist.Subplot(fig, rect)
 fig.add_subplot(ax)
 
 ax.set_yticks([0.2, 0.8])
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_pad.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_pad.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axis_pad.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,14 +1,14 @@
 
 
 import numpy as np
-import mpl_toolkits.axes_grid.angle_helper as angle_helper
-import mpl_toolkits.axes_grid.grid_finder as grid_finder
+import mpl_toolkits.axisartist.angle_helper as angle_helper
+import mpl_toolkits.axisartist.grid_finder as grid_finder
 from matplotlib.projections import PolarAxes
 from matplotlib.transforms import Affine2D
 
-import mpl_toolkits.axes_grid.axislines as axislines
+import mpl_toolkits.axisartist as axisartist
 
-from mpl_toolkits.axes_grid.grid_helper_curvelinear import GridHelperCurveLinear
+from mpl_toolkits.axisartist.grid_helper_curvelinear import GridHelperCurveLinear
 
 
 def setup_axes(fig, rect):
@@ -39,7 +39,7 @@
 )
 
 
- ax1 = axislines.Subplot(fig, rect, grid_helper=grid_helper)
+ ax1 = axisartist.Subplot(fig, rect, grid_helper=grid_helper)
 #ax1.axis[:].toggle(all=False)
 ax1.axis[:].set_visible(False)
 
Added: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py	 (rev 0)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -0,0 +1,22 @@
+import matplotlib.pyplot as plt
+import mpl_toolkits.axisartist as AA
+
+fig = plt.figure(1)
+fig.subplots_adjust(right=0.85)
+ax = AA.Subplot(fig, 1, 1, 1)
+fig.add_subplot(ax)
+
+# make some axis invisible
+ax.axis["bottom", "top", "right"].set_visible(False)
+
+# make an new axis along the first axis axis (x-axis) which pass
+# throught y=0.
+ax.axis["y=0"] = ax.new_floating_axis(nth_coord=0, value=0,
+ axis_direction="bottom")
+ax.axis["y=0"].toggle(all=True)
+ax.axis["y=0"].label.set_text("y = 0")
+
+ax.set_ylim(-2, 4)
+
+plt.show()
+
Added: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_colorbar.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_colorbar.py	 (rev 0)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_colorbar.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -0,0 +1,14 @@
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid1 import make_axes_locatable
+import numpy as np
+
+ax = plt.subplot(111)
+im = ax.imshow(np.arange(100).reshape((10,10)))
+
+# create an axes on the right side of ax. The width of cax will be 5%
+# of ax and the padding between cax and ax will be fixed at 0.05 inch.
+divider = make_axes_locatable(ax)
+cax = divider.append_axes("right", size="5%", pad=0.05)
+
+plt.colorbar(im, cax=cax)
+
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_rgb.py
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_rgb.py	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_rgb.py	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,6 +1,6 @@
 import matplotlib.pyplot as plt
 
-from mpl_toolkits.axes_grid.axes_rgb import RGBAxes
+from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
 
 def get_demo_image():
 import numpy as np
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/index.rst
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/index.rst	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/index.rst	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -13,13 +13,30 @@
 
 .. image:: ../../_static/demo_axes_grid.png
 
+.. note:: 
+ AxesGrid toolkit has been a part of matplotlib since v
+ 0.99. Originally, the toolkit had a single namespace of 
+ *axes_grid*. In more recent version (since svn r8226), the toolkit 
+ has divided into two separate namespace (*axes_grid1* and *axisartist*).
+ While *axes_grid* namespace is maintained for he backward compatibility,
+ use of *axes_grid1* and *axisartist* is recommended.
 
+.. warning:: 
+ *axes_grid* and *axisartist* (but not *axes_grid1*) uses
+ a custome Axes class (derived from the mpl's original Axes class).
+ As a sideeffect, some commands (mostly tick-related) do not work.
+ Use *axes_grid1* to avoid this, or see how things are different in
+ *axes_grid* and *axisartist* (LINK needed)
+
+
+
 Documentation
 =============
 
 .. toctree::
 :maxdepth: 2
 
+ users/overview.rst
 users/index.rst
 howtos/index.rst
 api/index.rst
Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axisartist.rst (from rev 8246, trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst)
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axisartist.rst	 (rev 0)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axisartist.rst	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -0,0 +1,456 @@
+.. _axisartist-manual:
+
+====================
+AXISARTIST namespace
+====================
+
+The AxisArtist namesapce includes a derived Axes implementation. The
+biggest difference is that the artists responsible to draw axis line,
+ticks, ticklabel and axis labels are separated out from the mpl's Axis
+class, which are much more than artists in the original mpl. This
+change was strongly motivated to support curvlinear grid. Here are a
+few things that mpl_tootlkits.axisartist.Axes is different from original
+Axes from mpl.
+
+* Axis elements (axis line(spine), ticks, ticklabel and axis labels)
+ are drawn by a AxisArtist instance. Unlike Axis, left, right, top
+ and bottom axis are drawn by separate artists. And each of them may
+ have different tick location and different tick labels.
+
+* gridlines are drawn by a Gridlines instance. The change was
+ motivated that in curvelinear coordinate, a gridline may not cross
+ axis-lines (i.e., no associated ticks). In the original Axes class,
+ gridlines are tied to ticks.
+
+* ticklines can be rotated if necessary (i.e, along the gridlines)
+
+In summary, all these changes was to support
+
+* a curvelinear grid.
+* a floating axis
+
+.. plot:: mpl_toolkits/axes_grid/examples/demo_floating_axis.py
+
+
+*mpl_toolkits.axisartist.Axes* class defines a *axis* attribute, which
+is a dictionary of AxisArtist instances. By default, the dictionary
+has 4 AxisArtist instances, responsible for drawing of left, right,
+bottom and top axis.
+
+xaxis and yaxis attributes are still available, however they are set
+to not visible. As separate artists are used for rendering axis, some
+axis-related method in mpl may have no effect.
+In addition to AxisArtist instances, the mpl_toolkits.axisartist.Axes will
+have *gridlines* attribute (Gridlines), which obviously draws grid
+lines.
+
+In both AxisArtist and Gridlines, the calculation of tick and grid
+location is delegated to an instance of GridHelper class.
+mpl_toolkits.axisartist.Axes class uses GridHelperRectlinear as a grid
+helper. The GridHelperRectlinear class is a wrapper around the *xaxis*
+and *yaxis* of mpl's original Axes, and it was meant to work as the
+way how mpl's original axes works. For example, tick location changes
+using set_ticks method and etc. should work as expected. But change in
+artist properties (e.g., color) will not work in general, although
+some effort has been made so that some often-change attributes (color,
+etc.) are respected.
+
+
+AxisArtist
+==========
+
+AxisArtist can be considered as a container artist with following
+attributes which will draw ticks, labels, etc.
+
+ * line
+ * major_ticks, major_ticklabels
+ * minor_ticks, minor_ticklabels
+ * offsetText
+ * label
+
+
+line
+----
+
+Derived from Line2d class. Responsible for drawing a spinal(?) line.
+
+major_ticks, minor_ticks
+------------------------
+
+Derived from Line2d class. Note that ticks are markers.
+
+
+major_ticklabels, minor_ticklabels
+----------------------------------
+
+Derived from Text. Note that it is not a list of Text artist, but a
+single artist (similar to a collection).
+
+axislabel
+---------
+
+Derived from Text.
+
+
+Default AxisArtists
+-------------------
+
+By default, following for axis artists are defined.::
+
+ ax.axis["left"], ax.axis["bottom"], ax.axis["right"], ax.axis["top"]
+
+The ticklabels and axislabel of the top and the right axis are set to
+not visible.
+
+For example, if you want to change the color attributes of
+major_ticklabels of the bottom x-axis ::
+
+ ax.axis["bottom"].major_ticklabels.set_color("b")
+
+Similarly, to make ticklabels invisible ::
+
+ ax.axis["bottom"].major_ticklabels.set_visible(False)
+
+AxisAritst provides a helper method to control the visibility of ticks, ticklabels, and label. To make ticklabel invisible, ::
+
+ ax.axis["bottom"].toggle(ticklabels=False)
+
+To make all of ticks, ticklabels, and (axis) label invisible ::
+ 
+ ax.axis["bottom"].toggle(all=False)
+ 
+To turn all off but ticks on ::
+ 
+ ax.axis["bottom"].toggle(all=False, ticks=True)
+ 
+To turn all on but (axis) label off ::
+ 
+ ax.axis["bottom"].toggle(all=True, label=False))
+
+
+ax.axis's __getitem__ method can take multiple axis names. For
+example, to turn ticklabels of "top" and "right" axis on, ::
+
+ ax.axis["top","right"].toggle(ticklabels=True))
+
+Note that 'ax.axis["top","right"]' returns a simple proxy object that translate above code to something like below. ::
+
+ for n in ["top","right"]:
+ ax.axis[n].toggle(ticklabels=True))
+
+So, any return values in the for loop are ignored. And you shoud not
+use it anything more than a simple method. 
+
+Like the list indexing ":" means all items, i.e., ::
+
+ ax.axis[:].major_ticks.set_color("r")
+
+changes tick color in all axis.
+
+
+HowTo
+=====
+
+1. Changing tick locations and label.
+
+ Same as the original mpl's axes.::
+
+ ax.set_xticks([1,2,3])
+
+2. Changing axis properties like color, etc.
+
+ Change the properties of appropriate artists. For example, to change
+ the color of the ticklabels::
+
+ ax.axis["left"].major_ticklabels.set_color("r")
+
+3. To change the attributes of multiple axis::
+
+ ax.axis["left","bottom"].major_ticklabels.set_color("r")
+
+ or to change the attributes of all axis::
+
+ ax.axis[:].major_ticklabels.set_color("r")
+
+4. To change the tick size (length), you need to use
+ axis.major_ticks.set_ticksize method. To change the direction of
+ the ticks (ticks are in opposite direction of ticklabels by
+ default), use axis.major_ticks.set_tick_out method.
+
+ To change the pad between ticks and ticklabels, use
+ axis.major_ticklabels.set_pad method.
+
+ To change the pad between ticklabels and axis label,
+ axis.label.set_pad method.
+
+
+Rotaion and Alignment of TickLabels
+===================================
+
+This is also quite different from the original mpl and can be
+confusing. When you want to rotate the ticklabels, first consider
+using "set_axis_direction" method. ::
+
+ ax1.axis["left"].major_ticklabels.set_axis_direction("top")
+ ax1.axis["right"].label.set_axis_direction("left")
+
+.. plot:: mpl_toolkits/axes_grid/figures/simple_axis_direction01.py
+
+The parameter for set_axis_direction is one of ["left", "right",
+"bottom", "top"].
+
+You must understand some underlying concept of directions.
+
+ 1. There is a reference direction which is defined as the direction
+ of the axis line with increasing coordinate. For example, the
+ reference direction of the left x-axis is from bottom to top.
+
+ .. plot:: mpl_toolkits/axes_grid/figures/axis_direction_demo_step01.py
+
+ The direction, text angle, and alignments of the ticks, ticklabels and
+ axis-label is determined with respect to the reference direction
+
+ 2. *ticklabel_direction* is either the right-hand side (+) of the
+ reference direction or the left-hand side (-).
+
+ .. plot:: mpl_toolkits/axes_grid/figures/axis_direction_demo_step02.py
+
+ 3. same for the *label_direction*
+
+ .. plot:: mpl_toolkits/axes_grid/figures/axis_direction_demo_step03.py
+
+ 4. ticks are by default drawn toward the opposite direction of the ticklabels.
+
+ 5. text rotation of ticklabels and label is determined in reference
+ to the *ticklabel_direction* or *label_direction*,
+ respectively. The rotation of ticklabels and label is anchored.
+
+ .. plot:: mpl_toolkits/axes_grid/figures/axis_direction_demo_step04.py
+
+
+On the other hand, there is a concept of "axis_direction". This is a
+default setting of above properties for each, "bottom", "left", "top",
+and "right" axis. 
+
+ ========== =========== ========= ========== ========= ==========
+ ? ? left bottom right top
+ ---------- ----------- --------- ---------- --------- ----------
+ axislabel direction '-' '+' '+' '-'
+ axislabel rotation 180 0 0 180
+ axislabel va center top center bottom
+ axislabel ha right center right center
+ ticklabel direction '-' '+' '+' '-'
+ ticklabels rotation 90 0 -90 180
+ ticklabel ha right center right center
+ ticklabel va center baseline center baseline
+ ========== =========== ========= ========== ========= ==========
+ 
+
+And, 'set_axis_direction("top")' means to adjust the text rotation
+etc, for settings suitable for "top" axis. The concept of axis
+direction can be more clear with curved axis.
+
+.. plot:: mpl_toolkits/axes_grid/figures/demo_axis_direction.py
+
+The axis_drection can be adjusted in the AxisArtist level, or in the
+level of its child arists, i.e., ticks, ticklabels, and axis-label. ::
+
+ ax1.axis["left"].set_axis_direction("top")
+
+changes axis_direction of all the associated artist with the "left"
+axis, while ::
+
+ ax1.axis["left"].major_ticklabels.set_axis_direction("top")
+
+changes the axis_direction of only the major_ticklabels. Note that
+set_axis_direction in the AxisArtist level changes the
+ticklabel_direction and label_direction, while chainging the
+axis_direction of ticks, ticklabels, and axis-label does not affect
+them.
+
+
+If you want to make ticks outward and ticklabels inside the axes, 
+use invert_ticklabel_direction method. ::
+
+ ax.axis[:].invert_ticklabel_direction()
+ 
+A related method is "set_tick_out". It makes ticks outward (as a
+matter of fact, it makes ticks toward the opposite direction of the
+default direction). ::
+
+ ax.axis[:].major_ticks.set_tick_out(True)
+
+.. plot:: mpl_toolkits/axes_grid/figures/simple_axis_direction03.py
+
+
+So, in summary, 
+
+ * AxisArtist's methods
+ * set_axis_direction : "left", "right", "bottom", or "top"
+ * set_ticklabel_direction : "+" or "-"
+ * set_axislabel_direction : "+" or "-"
+ * invert_ticklabel_direction
+ * Ticks' methods (major_ticks and minor_ticks)
+ * set_tick_out : True or False
+ * set_ticksize : size in points
+ * TickLabels' methods (major_ticklabels and minor_ticklabels)
+ * set_axis_direction : "left", "right", "bottom", or "top"
+ * set_rotation : angle with respect to the renference direction
+ * set_ha and set_va : see below
+ * AxisLabels' methods (label)
+ * set_axis_direction : "left", "right", "bottom", or "top"
+ * set_rotation : angle with respect to the renference direction
+ * set_ha and set_va
+
+
+
+Adjusting ticklabels alignment
+------------------------------
+
+Alignment of TickLabels are treated specially. See below
+
+.. plot:: mpl_toolkits/axes_grid/figures/demo_ticklabel_alignment.py
+
+Adjusting pad
+--------------
+
+To change the pad between ticks and ticklabels ::
+
+ ax.axis["left"].major_ticklabels.set_pad(10)
+
+Or ticklabels and axis-label ::
+
+ ax.axis["left"].label.set_pad(10)
+
+
+.. plot:: mpl_toolkits/axes_grid/figures/simple_axis_pad.py
+
+
+GridHelper
+==========
+
+To actually define a curvelinear coordinate, you have to use your own
+grid helper. A generalised version of grid helper class is supplied
+and this class should suffice in most of cases. A user may provide
+two functions which defines a transformation (and its inverse pair)
+from the curved coordinate to (rectlinear) image coordinate. Note that
+while ticks and grids are drawn for curved coordinate, the data
+transform of the axes itself (ax.transData) is still rectlinear
+(image) coordinate. ::
+
+
+ from mpl_toolkits.axisartist.grid_helper_curvelinear \
+ import GridHelperCurveLinear
+ from mpl_toolkits.axisartist import Subplot
+
+ # from curved coordinate to rectlinear coordinate.
+ def tr(x, y):
+ x, y = np.asarray(x), np.asarray(y)
+ return x, y-x
+
+ # from rectlinear coordinate to curved coordinate.
+ def inv_tr(x,y):
+ x, y = np.asarray(x), np.asarray(y)
+ return x, y+x
+
+
+ grid_helper = GridHelperCurveLinear((tr, inv_tr))
+
+ ax1 = Subplot(fig, 1, 1, 1, grid_helper=grid_helper)
+
+ fig.add_subplot(ax1)
+
+
+You may use matplotlib's Transform instance instead (but a
+inverse transformation must be defined). Often, coordinate range in a
+curved coordinate system may have a limited range, or may have
+cycles. In those cases, a more customized version of grid helper is
+required. ::
+
+
+ import mpl_toolkits.axisartist.angle_helper as angle_helper
+
+ # PolarAxes.PolarTransform takes radian. However, we want our coordinate
+ # system in degree
+ tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
+
+
+ # extreme finder : find a range of coordinate.
+ # 20, 20 : number of sampling points along x, y direction
+ # The first coordinate (longitude, but theta in polar)
+ # has a cycle of 360 degree.
+ # The second coordinate (latitude, but radius in polar) has a minimum of 0
+ extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
+ lon_cycle = 360,
+ lat_cycle = None,
+ lon_minmax = None,
+ lat_minmax = (0, np.inf),
+ )
+
+ # Find a grid values appropriate for the coordinate (degree,
+ # minute, second). The argument is a approximate number of grids.
+ grid_locator1 = angle_helper.LocatorDMS(12)
+
+ # And also uses an appropriate formatter. Note that,the
+ # acceptable Locator and Formatter class is a bit different than
+ # that of mpl's, and you cannot directly use mpl's Locator and
+ # Formatter here (but may be possible in the future).
+ tick_formatter1 = angle_helper.FormatterDMS()
+
+ grid_helper = GridHelperCurveLinear(tr,
+ extreme_finder=extreme_finder,
+ grid_locator1=grid_locator1,
+ tick_formatter1=tick_formatter1
+ )
+
+
+Again, the *transData* of the axes is still a rectlinear coordinate
+(image coordinate). You may manually do conversion between two
+coordinates, or you may use Parasite Axes for convenience.::
+
+ ax1 = SubplotHost(fig, 1, 2, 2, grid_helper=grid_helper)
+
+ # A parasite axes with given transform
+ ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
+ # note that ax2.transData == tr + ax1.transData
+ # Anthing you draw in ax2 will match the ticks and grids of ax1.
+ ax1.parasites.append(ax2)
+
+
+.. plot:: mpl_toolkits/axes_grid/examples/demo_curvelinear_grid.py
+
+
+
+FloatingAxis
+============
+
+A floating axis is an axis one of whose data coordinate is fixed, i.e,
+its location is not fixed in Axes coordinate but changes as axes data
+limits changes. A floating axis can be created using
+*new_floating_axis* method. However, it is your responsibility that
+the resulting AxisArtist is properly added to the axes. A recommended
+way is to add it as an item of Axes's axis attribute.::
+
+ # floating axis whose first (index starts from 0) coordinate
+ # (theta) is fixed at 60
+
+ ax1.axis["lat"] = axis = ax1.new_floating_axis(0, 60)
+ axis.label.set_text(r"$\theta = 60^{\circ}$")
+ axis.label.set_visible(True)
+
+
+See the first example of this page.
+
+Current Limitations and TODO's
+==============================
+
+The code need more refinement. Here is a incomplete list of issues and TODO's
+
+* No easy way to support a user customized tick location (for
+ curvelinear grid). A new Locator class needs to be created.
+
+* FloatingAxis may have coordinate limits, e.g., a floating axis of x
+ = 0, but y only spans from 0 to 1.
+
+* The location of axislabel of FloatingAxis needs to be optionally
+ given as a coordinate value. ex, a floating axis of x=0 with label at y=1
Deleted: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,456 +0,0 @@
-.. _axislines-manual:
-
-=========
-Axislines
-=========
-
-Axislines includes a derived Axes implementation. The
-biggest difference is that the artists responsible to draw axis line,
-ticks, ticklabel and axis labels are separated out from the mpl's Axis
-class, which are much more than artists in the original
-mpl. This change was strongly motivated to support curvlinear
-grid. Here are a few things that axes_grid.axislines.Axes is different
-from original Axes from mpl.
-
-* Axis elements (axis line(spine), ticks, ticklabel and axis labels)
- are drawn by a AxisArtist instance. Unlike Axis, left, right, top
- and bottom axis are drawn by separate artists. And each of them may
- have different tick location and different tick labels.
-
-* gridlines are drawn by a Gridlines instance. The change was
- motivated that in curvelinear coordinate, a gridline may not cross
- axislines (i.e., no associated ticks). In the original Axes class,
- gridlines are tied to ticks.
-
-* ticklines can be rotated if necessary (i.e, along the gridlines)
-
-In summary, all these changes was to support
-
-* a curvelinear grid.
-* a floating axis
-
-.. plot:: mpl_toolkits/axes_grid/examples/demo_floating_axis.py
-
-
-*axes_grid.axislines.Axes* defines a *axis* attribute, which is a
-dictionary of AxisArtist instances. By default, the dictionary has 4
-AxisArtist instances, responsible for drawing of left, right, bottom
-and top axis.
-
-xaxis and yaxis attributes are still available, however they are set
-to not visible. As separate artists are used for rendering axis, some
-axis-related method in mpl may have no effect.
-In addition to AxisArtist instances, the axes_grid.axislines.Axes will
-have *gridlines* attribute (Gridlines), which obviously draws grid
-lines.
-
-In both AxisArtist and Gridlines, the calculation of tick and grid
-location is delegated to an instance of GridHelper class.
-axes_grid.axislines.Axes class uses GridHelperRectlinear as a grid
-helper. The GridHelperRectlinear class is a wrapper around the *xaxis*
-and *yaxis* of mpl's original Axes, and it was meant to work as the
-way how mpl's original axes works. For example, tick location changes
-using set_ticks method and etc. should work as expected. But change in
-artist properties (e.g., color) will not work in general, although
-some effort has been made so that some often-change attributes (color,
-etc.) are respected.
-
-
-AxisArtist
-==========
-
-AxisArtist can be considered as a container artist with following
-attributes which will draw ticks, labels, etc.
-
- * line
- * major_ticks, major_ticklabels
- * minor_ticks, minor_ticklabels
- * offsetText
- * label
-
-
-line
-----
-
-Derived from Line2d class. Responsible for drawing a spinal(?) line.
-
-major_ticks, minor_ticks
-------------------------
-
-Derived from Line2d class. Note that ticks are markers.
-
-
-major_ticklabels, minor_ticklabels
-----------------------------------
-
-Derived from Text. Note that it is not a list of Text artist, but a
-single artist (similar to a collection).
-
-axislabel
----------
-
-Derived from Text.
-
-
-Default AxisArtists
--------------------
-
-By default, following for axis artists are defined.::
-
- ax.axis["left"], ax.axis["bottom"], ax.axis["right"], ax.axis["top"]
-
-The ticklabels and axislabel of the top and the right axis are set to
-not visible.
-
-For example, if you want to change the color attributes of
-major_ticklabels of the bottom x-axis ::
-
- ax.axis["bottom"].major_ticklabels.set_color("b")
-
-Similarly, to make ticklabels invisible ::
-
- ax.axis["bottom"].major_ticklabels.set_visible(False)
-
-AxisAritst provides a helper method to control the visibility of ticks, ticklabels, and label. To make ticklabel invisible, ::
-
- ax.axis["bottom"].toggle(ticklabels=False)
-
-To make all of ticks, ticklabels, and (axis) label invisible ::
- 
- ax.axis["bottom"].toggle(all=False)
- 
-To turn all off but ticks on ::
- 
- ax.axis["bottom"].toggle(all=False, ticks=True)
- 
-To turn all on but (axis) label off ::
- 
- ax.axis["bottom"].toggle(all=True, label=False))
-
-
-ax.axis's __getitem__ method can take multiple axis names. For
-example, to turn ticklabels of "top" and "right" axis on, ::
-
- ax.axis["top","right"].toggle(ticklabels=True))
-
-Note that 'ax.axis["top","right"]' returns a simple proxy object that translate above code to something like below. ::
-
- for n in ["top","right"]:
- ax.axis[n].toggle(ticklabels=True))
-
-So, any return values in the for loop are ignored. And you shoud not
-use it anything more than a simple method. 
-
-Like the list indexing ":" means all items, i.e., ::
-
- ax.axis[:].major_ticks.set_color("r")
-
-changes tick color in all axis.
-
-
-HowTo
-=====
-
-1. Changing tick locations and label.
-
- Same as the original mpl's axes.::
-
- ax.set_xticks([1,2,3])
-
-2. Changing axis properties like color, etc.
-
- Change the properties of appropriate artists. For example, to change
- the color of the ticklabels::
-
- ax.axis["left"].major_ticklabels.set_color("r")
-
-3. To change the attributes of multiple axis::
-
- ax.axis["left","bottom"].major_ticklabels.set_color("r")
-
- or to change the attributes of all axis::
-
- ax.axis[:].major_ticklabels.set_color("r")
-
-4. To change the tick size (length), you need to use
- axis.major_ticks.set_ticksize method. To change the direction of
- the ticks (ticks are in opposite direction of ticklabels by
- default), use axis.major_ticks.set_tick_out method.
-
- To change the pad between ticks and ticklabels, use
- axis.major_ticklabels.set_pad method.
-
- To change the pad between ticklabels and axis label,
- axis.label.set_pad method.
-
-
-Rotaion and Alignment of TickLabels
-===================================
-
-This is also quite different from the original mpl and can be
-confusing. When you want to rotate the ticklabels, first consider
-using "set_axis_direction" method. ::
-
- ax1.axis["left"].major_ticklabels.set_axis_direction("top")
- ax1.axis["right"].label.set_axis_direction("left")
-
-.. plot:: mpl_toolkits/axes_grid/figures/simple_axis_direction01.py
-
-The parameter for set_axis_direction is one of ["left", "right",
-"bottom", "top"].
-
-You must understand some underlying concept of directions.
-
- 1. There is a reference direction which is defined as the direction
- of the axis line with increasing coordinate. For example, the
- reference direction of the left x-axis is from bottom to top.
-
- .. plot:: mpl_toolkits/axes_grid/figures/axis_direction_demo_step01.py
-
- The direction, text angle, and alignments of the ticks, ticklabels and
- axis-label is determined width respect to the reference direction
-
- 2. *ticklabel_direction* is either the right-hand side (+) of the
- reference direction or the left-hand side (-).
-
- .. plot:: mpl_toolkits/axes_grid/figures/axis_direction_demo_step02.py
-
- 3. same for the *label_direction*
-
- .. plot:: mpl_toolkits/axes_grid/figures/axis_direction_demo_step03.py
-
- 4. ticks are by default drawn toward the opposite direction of the ticklabels.
-
- 5. text rotation of ticklabels and label is determined in reference
- to the *ticklabel_direction* or *label_direction*,
- respectively. The rotation of ticklabels and tlabel is anchored.
-
- .. plot:: mpl_toolkits/axes_grid/figures/axis_direction_demo_step04.py
-
-
-On the other hand, there is a concept of "axis_direction". This is a
-default setting of above properties for each, "bottom", "left", "top",
-and "right" axis. 
-
- ========== =========== ========= ========== ========= ==========
- ? ? left bottom right top
- ---------- ----------- --------- ---------- --------- ----------
- axislabel direction '-' '+' '+' '-'
- axislabel rotation 180 0 0 180
- axislabel va center top center bottom
- axislabel ha right center right center
- ticklabel direction '-' '+' '+' '-'
- ticklabels rotation 90 0 -90 180
- ticklabel ha right center right center
- ticklabel va center baseline center baseline
- ========== =========== ========= ========== ========= ==========
- 
-
-And, 'set_axis_direction("top")' means to adjust the text rotation
-etc, for settings suitable for "top" axis. The concept of axis
-direction can be more clear with curved axis.
-
-.. plot:: mpl_toolkits/axes_grid/figures/demo_axis_direction.py
-
-The axis_drection can be adjusted in the AxisArtist level, or in the
-level of its child arists, i.e., ticks, ticklabels, and axis-label. ::
-
- ax1.axis["left"].set_axis_direction("top")
-
-changes axis_direction of all the associated artist with the "left"
-axis, while ::
-
- ax1.axis["left"].major_ticklabels.set_axis_direction("top")
-
-changes the axis_direction of only the major_ticklabels. Note that
-set_axis_direction in the AxisArtist level changes the
-ticklabel_direction and label_direction, while chainging the
-axis_direction of ticks, ticklabels, and axis-label does not affect
-them.
-
-
-If you want to make ticks outward and ticklabels inside the axes, 
-use invert_ticklabel_direction method. ::
-
- ax.axis[:].invert_ticklabel_direction()
- 
-A related method is "set_tick_out". It makes ticks outward (as a
-matter of fact, it makes ticks toward the opposite direction of the
-default direction). ::
-
- ax.axis[:].major_ticks.set_tick_out(True)
-
-.. plot:: mpl_toolkits/axes_grid/figures/simple_axis_direction03.py
-
-
-So, in summary, 
-
- * AxisArtist's methods
- * set_axis_direction : "left", "right", "bottom", or "top"
- * set_ticklabel_direction : "+" or "-"
- * set_axislabel_direction : "+" or "-"
- * invert_ticklabel_direction
- * Ticks' methods (major_ticks and minor_ticks)
- * set_tick_out : True or False
- * set_ticksize : size in points
- * TickLabels' methods (major_ticklabels and minor_ticklabels)
- * set_axis_direction : "left", "right", "bottom", or "top"
- * set_rotation : angle with respect to the renference direction
- * set_ha and set_va : see below
- * AxisLabels' methods (label)
- * set_axis_direction : "left", "right", "bottom", or "top"
- * set_rotation : angle with respect to the renference direction
- * set_ha and set_va
-
-
-
-Adjusting ticklabels alignment
-------------------------------
-
-Alignment of TickLabels are treated specially. See below
-
-.. plot:: mpl_toolkits/axes_grid/figures/demo_ticklabel_alignment.py
-
-Adjusting pad
---------------
-
-To change the pad between ticks and ticklabels ::
-
- ax.axis["left"].major_ticklabels.set_pad(10)
-
-Or ticklabels and axis-label ::
-
- ax.axis["left"].label.set_pad(10)
-
-
-.. plot:: mpl_toolkits/axes_grid/figures/simple_axis_pad.py
-
-
-GridHelper
-==========
-
-To actually define a curvelinear coordinate, you have to use your own
-grid helper. A generalised version of grid helper class is supplied
-and this class should be suffice in most of cases. A user may provide
-two functions which defines a transformation (and its inverse pair)
-from the curved coordinate to (rectlinear) image coordinate. Note that
-while ticks and grids are drawn for curved coordinate, the data
-transform of the axes itself (ax.transData) is still rectlinear
-(image) coordinate. ::
-
-
- from mpl_toolkits.axes_grid.grid_helper_curvelinear \
- import GridHelperCurveLinear
- from mpl_toolkits.axes_grid.axislines import Subplot
-
- # from curved coordinate to rectlinear coordinate.
- def tr(x, y):
- x, y = np.asarray(x), np.asarray(y)
- return x, y-x
-
- # from rectlinear coordinate to curved coordinate.
- def inv_tr(x,y):
- x, y = np.asarray(x), np.asarray(y)
- return x, y+x
-
-
- grid_helper = GridHelperCurveLinear((tr, inv_tr))
-
- ax1 = Subplot(fig, 1, 1, 1, grid_helper=grid_helper)
-
- fig.add_subplot(ax1)
-
-
-You may use matplotlib's Transform instance instead (but a
-inverse transformation must be defined). Often, coordinate range in a
-curved coordinate system may have a limited range, or may have
-cycles. In those cases, a more customized version of grid helper is
-required. ::
-
-
- import mpl_toolkits.axes_grid.angle_helper as angle_helper
-
- # PolarAxes.PolarTransform takes radian. However, we want our coordinate
- # system in degree
- tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
-
-
- # extreme finder : find a range of coordinate.
- # 20, 20 : number of sampling points along x, y direction
- # The first coordinate (longitude, but theta in polar)
- # has a cycle of 360 degree.
- # The second coordinate (latitude, but radius in polar) has a minimum of 0
- extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
- lon_cycle = 360,
- lat_cycle = None,
- lon_minmax = None,
- lat_minmax = (0, np.inf),
- )
-
- # Find a grid values appropriate for the coordinate (degree,
- # minute, second). The argument is a approximate number of grids.
- grid_locator1 = angle_helper.LocatorDMS(12)
-
- # And also uses an appropriate formatter. Note that,the
- # acceptable Locator and Formatter class is a bit different than
- # that of mpl's, and you cannot directly use mpl's Locator and
- # Formatter here (but may be possible in the future).
- tick_formatter1 = angle_helper.FormatterDMS()
-
- grid_helper = GridHelperCurveLinear(tr,
- extreme_finder=extreme_finder,
- grid_locator1=grid_locator1,
- tick_formatter1=tick_formatter1
- )
-
-
-Again, the *transData* of the axes is still a rectlinear coordinate
-(image coordinate). You may manually do conversion between two
-coordinates, or you may use Parasite Axes for convenience.::
-
- ax1 = SubplotHost(fig, 1, 2, 2, grid_helper=grid_helper)
-
- # A parasite axes with given transform
- ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
- # note that ax2.transData == tr + ax1.transData
- # Anthing you draw in ax2 will match the ticks and grids of ax1.
- ax1.parasites.append(ax2)
-
-
-.. plot:: mpl_toolkits/axes_grid/examples/demo_curvelinear_grid.py
-
-
-
-FloatingAxis
-============
-
-A floating axis is an axis one of whose data coordinate is fixed, i.e,
-its location is not fixed in Axes coordinate but changes as axes data
-limits changes. A floating axis can be created using
-*new_floating_axis* method. However, it is your responsibility that
-the resulting AxisArtist is properly added to the axes. A recommended
-way is to add it as an item of Axes's axis attribute.::
-
- # floating axis whose first (index starts from 0) coordinate
- # (theta) is fixed at 60
-
- ax1.axis["lat"] = axis = ax1.new_floating_axis(0, 60)
- axis.label.set_text(r"$\theta = 60^{\circ}$")
- axis.label.set_visible(True)
-
-
-See the first example of this page.
-
-Current Limitations and TODO's
-==============================
-
-The code need more refinement. Here is a incomplete list of issues and TODO's
-
-* No easy way to support a user customized tick location (for
- curvelinear grid). A new Locator class needs to be created.
-
-* FloatingAxis may have coordinate limits, e.g., a floating axis of x
- = 0, but y only spans from 0 to 1.
-
-* The location of axislabel of FloatingAxis needs to be optionally
- given as a coordinate value. ex, a floating axis of x=0 with label at y=1
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/index.rst
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/index.rst	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/index.rst	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -9,6 +9,6 @@
 
 .. toctree::
 
- overview.rst
 axes_divider.rst
- axislines.rst
+ axisartist.rst
+
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst	2010年04月20日 16:43:42 UTC (rev 8246)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst	2010年04月20日 16:44:01 UTC (rev 8247)
@@ -1,7 +1,10 @@
-========
-Overview
-========
+============================
+Overview of AxesGrid toolkit
+============================
 
+What is AxesGrid toolkit?
+=========================
+
 The matplotlib AxesGrid toolkit is a collection of helper classes,
 mainly to ease displaying (multiple) images in matplotlib.
 
@@ -9,30 +12,65 @@
 :depth: 1
 :local:
 
-`AxesGrid`_, `RGB Axes`_ and `AxesDivider`_ are helper classes that
-deals with adjusting the location of (multiple) Axes, mainly for
-displaying images. It provides a framework to adjust the position of
-multiple axes at the drawing time. `ParasiteAxes`_ provides twinx(or
-twiny)-like features so that you can plot different data (e.g.,
-different y-scale) in a same Axes. `AxisLine`_ is a custom Axes
-class. Unlike default Axes in matpotlib, each axis (left, right, top
-and bottom) is associated with a separate artist (which is resposible
-to draw axis-line, ticks, ticklabels, label). `AnchoredArtists`_
+.. note:: 
+ AxesGrid toolkit has been a part of matplotlib since v
+ 0.99. Originally, the toolkit had a single namespace of 
+ *axes_grid*. In more recent version (since svn r8226), the toolkit 
+ has divided into two separate namespace (*axes_grid1* and *axisartist*).
+ While *axes_grid* namespace is maintained for he backward compatibility,
+ use of *axes_grid1* and *axisartist* is recommended.
+
+.. warning:: 
+ *axes_grid* and *axisartist* (but not *axes_grid1*) uses
+ a custome Axes class (derived from the mpl's original Axes class).
+ As a sideeffect, some commands (mostly tick-related) do not work.
+ Use *axes_grid1* to avoid this, or see how things are different in
+ *axes_grid* and *axisartist* (LINK needed)
+
+
+AxesGrid toolkit has two namespaces (*axes_grid1* and *axisartist*).
+*axisartist* contains custome Axes class that is meant to support for
+curvilinear grids (e.g., the world coordinate system in astronomy).
+Unlike mpl's original Axes class which uses Axes.xaxis and Axes.yaxis
+to draw ticks, ticklines and etc., Axes in axisartist uses special
+artist (AxisArtist) which can handle tick, ticklines and etc. for
+curved coordinate systems.
+
+.. plot:: mpl_toolkits/axes_grid/examples/demo_floating_axis.py
+
+Since it uses a special artists, some mpl commands that work on
+Axes.xaxis and Axes.yaxis may not work. See LINK for more detail.
+
+
+*axes_grid1* is a collection of helper classes to ease displaying
+(multiple) images with matplotlib. In matplotlib, the axes location
+(and size) is specified in the normalized figure coordinates, which
+may not be ideal for displaying images that needs to have a given
+aspect ratio. For example, it helps you to have a colobar whose
+height always matches that of the image. `AxesGrid`_, `RGB Axes`_ and
+`AxesDivider`_ are helper classes that deals with adjusting the
+location of (multiple) Axes. They provides a framework to adjust the
+position of multiple axes at the drawing time. `ParasiteAxes`_
+provides twinx(or twiny)-like features so that you can plot different
+data (e.g., different y-scale) in a same Axes. `AnchoredArtists`_
 includes custom artists which are placed at some anchored position,
 like the legend.
 
+.. plot:: mpl_toolkits/axes_grid/examples/demo_axes_grid.py
 
 
+AXES_GRID1
+==========
 
-AxesGrid
-========
+ImageGrid
+---------
 
 
 A class that creates a grid of Axes. In matplotlib, the axes location
 (and size) is specified in the normalized figure coordinates. This may
 not be ideal for images that needs to be displayed with a given aspect
 ratio. For example, displaying images of a same size with some fixed
-padding between them cannot be easily done in matplotlib. AxesGrid is
+padding between them cannot be easily done in matplotlib. ImageGrid is
 used in such case.
 
 .. plot:: mpl_toolkits/axes_grid/examples/simple_axesgrid.py
@@ -60,7 +98,7 @@
 
 
 
-When initialized, AxesGrid creates given number (*ngrids* or *ncols* *
+When initialized, ImageGrid creates given number (*ngrids* or *ncols* *
 *nrows* if *ngrids* is None) of Axes instances. A sequence-like
 interface is provided to access the individual Axes instances (e.g.,
 grid[0] is the first Axes in the grid. See below for the order of
@@ -140,32 +178,10 @@
 .. plot:: mpl_toolkits/axes_grid/examples/demo_axes_grid.py
 
 
-RGB Axes
-========
-
-RGBAxes is a helper clase to conveniently show RGB composite
-images. Like AxesGrid, the location of axes are adjusted so that the
-area occupied by them fits in a given rectangle. Also, the xaxis and
-yaxis of each axes are shared. ::
-
- from mpl_toolkits.axes_grid.axes_rgb import RGBAxes
-
- fig = plt.figure(1)
- ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
-
- r, g, b = get_rgb() # r,g,b are 2-d images
- ax.imshow_rgb(r, g, b,
- origin="lower", interpolation="nearest")
-
-
-.. plot:: mpl_toolkits/axes_grid/figures/simple_rgb.py
-
-
-
 AxesDivider
-===========
+-----------
 
-Behind the scene, the AxesGrid class and the RGBAxes class utilize the
+Behind the scene, the ImageGrid class and the RGBAxes class utilize the
 AxesDivider class, whose role is to calculate the location of the axes
 at drawing time. While a more about the AxesDivider is (will be)
 explained in (yet to be written) AxesDividerGuide, direct use of the
@@ -181,44 +197,45 @@
 
 
 *make_axes_locatable* returns an isntance of the AxesLocator class,
-derived from the Locator. It has *new_vertical*, and *new_horizontal*
-methods. The *new_vertical* (*new_horizontal*) creates a new axes on
-the upper (right) side of the original axes.
+derived from the Locator. It provides *append_axes* method that
+creates a new axes on the given side of ("top", "right", "bottom" and
+"left") of the original axes.
 
 
-scatter_hist.py with AxesDivider
---------------------------------
 
-The "scatter_hist.py" example in mpl can be rewritten using
-*make_axes_locatable*. ::
+colorbar whose height (or width) in sync with the master axes
+-------------------------------------------------------------
 
- from mpl_toolkits.axes_grid import make_axes_locatable
+.. plot:: mpl_toolkits/axes_grid/figures/simple_colorbar.py
+ :include-source:
 
- axScatter = subplot(111)
- divider = make_axes_locatable(axScatter)
 
- # create new axes on the right and on the top of the current axes
- # The first argument of the new_vertical(new_horizontal) method is
- # the height (width) of the axes to be created in inches.
- axHistx = divider.new_vertical(1.2, pad=0.1, sharex=axScatter)
- axHisty = divider.new_horizontal(1.2, pad=0.1, sharey=axScatter)
 
- fig.add_axes(axHistx)
- fig.add_axes(axHisty)
 
+scatter_hist.py with AxesDivider
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
- # the scatter plot:
+The "scatter_hist.py" example in mpl can be rewritten using
+*make_axes_locatable*. ::
+
+ axScatter = subplot(111)
 axScatter.scatter(x, y)
 axScatter.set_aspect(1.)
 
+ # create new axes on the right and on the top of the current axes.
+ divider = make_axes_locatable(axScatter)
+ axHistx = divider.append_axes("top", size=1.2, pad=0.1, sharex=axScatter)
+ axHisty = divider.append_axes("right", size=1.2, pad=0.1, sharey=axScatter)
+
+ # the scatter plot:
 # histograms
 bins = np.arange(-lim, lim + binwidth, binwidth)
 axHistx.hist(x, bins=bins)
 axHisty.hist(y, bins=bins, orientation='horizontal')
 
+
 See the full source code below.
 
-
 .. plot:: mpl_toolkits/axes_grid/examples/scatter_hist.py
 
 
@@ -229,86 +246,42 @@
 
 
 ParasiteAxes
-============
+------------
 
-The ParasiteAxes is a axes whose location is identical to its host
+The ParasiteAxes is an axes whose location is identical to its host
 axes. The location is adjusted in the drawing time, thus it works even
-if the host change its location (e.g., images). It provides *twinx*,
-*twiny* (similar to twinx and twiny in the matplotlib). Also it
-provides *twin*, which takes an arbitraty tranfromation that maps
-between the data coordinates of the host and the parasite axes.
-Artists in each axes are mergred and drawn acrroding to their zorder.
-It also modifies some behavior of the axes. For example, color cycle
-for plot lines are shared between host and parasites. Also, the legend
-command in host, creates a legend that includes lines in the parasite
-axes.
+if the host change its location (e.g., images). 
 
+In most cases, you first create a host axes, which provides a few
+method that can be used to create parasite axes. They are *twinx*,
+*twiny* (which are similar to twinx and twiny in the matplotlib) and
+*twin*. *twin* takes an arbitraty tranfromation that maps between the
+data coordinates of the host axes and the parasite axes. *draw*
+method of the parasite axes are never called. Instead, host axes
+collects artists in parasite axes and draw them as if they belong to
+the host axes, i.e., artists in parasite axes are merged to those of
+the host axes and then drawn according to their zorder. The host and
+parasite axes modifies some of the axes behavior. For example, color
+cycle for plot lines are shared between host and parasites. Also, the
+legend command in host, creates a legend that includes lines in the
+parasite axes. To create a host axes, you may use *host_suplot* or
+*host_axes* command.
+
+
 Example 1. twinx
-----------------
+~~~~~~~~~~~~~~~~
 
 .. plot:: mpl_toolkits/axes_grid/figures/parasite_simple.py
 :include-source:
 
 Example 2. twin
----------------
+~~~~~~~~~~~~~~~
 
-A more sophiscated example using twin. Note that if you change the
-x-limit in the host axes, the x-limit of the parasite axes will change
-accordingly.
+*twin* without a transform argument treat the parasite axes to have a
+same data transform as the host. This can be useful when you want the
+top(or right)-axis to have different tick-locations, tick-labels, or
+tick-formatter for bottom(or left)-axis. ::
 
-
-.. plot:: mpl_toolkits/axes_grid/examples/parasite_simple2.py
-
-
-
-AxisLine
-========
-
-AxisLine is a custom (and very experimenta) Axes class, where each
-axis (left, right, top and bottom) have a separate artist associated
-(which is resposible to draw axis-line, ticks, ticklabels, label).
-Also, you can create your own axis, which can pass through a fixed
-position in the axes coordinate, or a fixed position in the data
-coordinate (i.e., the axis floats around when viewlimit changes).
-
-Most of the class in this toolkit is based on this class. And it has
-not been tested extensibly. You may go back to the original mpl
-behanvior, by ::
-
- ax.toggle_axisline(False)
-
-The axes class, by default, provides 4 artists which are responsible
-to draw axis in "left","right","bottom" and "top". They are accessed
-as ax.axis["left"], ax.axis["right"], and so on, i.e., ax.axis is a
-dictionary that contains artists (note that ax.axis is still a
-callable methods and it behaves as an original Axes.axis method in
-mpl).
-
-For example, you can hide right, and top axis by ::
-
- ax.axis["right"].set_visible(False)
- ax.axis["top"].set_visible(False)
-
-
-.. plot:: mpl_toolkits/axes_grid/figures/simple_axisline3.py
-
-
-SubplotZero gives you two more additional (floating?) axis of x=0 and
-y=0 (in data coordinate)
-
-.. plot:: mpl_toolkits/axes_grid/figures/simple_axisline2.py
- :include-source:
-
-
-Axisline with ParasiteAxes
---------------------------
-
-Most of axes class in the axes_grid toolkit, including ParasiteAxes,
-is based on the Axisline axes. The combination of the two can be
-useful in some case. For example, you can have different tick-location,
-tick-label, or tick-formatter for bottom and top (or left and right)
-axis. ::
-
 ax2 = ax.twin() # now, ax2 is responsible for "top" axis and "right" axis
 ax2.set_xticks([0., .5*np.pi, np.pi, 1.5*np.pi, 2*np.pi])
 ax2.set_xticklabels(["0", r"$\frac{1}{2}\pi$",
@@ -318,23 +291,17 @@
 .. plot:: mpl_toolkits/axes_grid/examples/simple_axisline4.py
 
 
-AxisLine Axes lets you create a custom axis, ::
 
- # make new (right-side) yaxis, but w...
 
[truncated message content]
From: <lee...@us...> - 2010年04月20日 16:43:48
Revision: 8246
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8246&view=rev
Author: leejjoon
Date: 2010年04月20日 16:43:42 +0000 (2010年4月20日)
Log Message:
-----------
minor tweaks on axes_grid1 to improve the usability
Modified Paths:
--------------
 trunk/matplotlib/lib/mpl_toolkits/axes_grid1/__init__.py
 trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_divider.py
 trunk/matplotlib/lib/mpl_toolkits/axes_grid1/parasite_axes.py
 trunk/matplotlib/lib/mpl_toolkits/axisartist/__init__.py
 trunk/matplotlib/lib/mpl_toolkits/axisartist/axislines.py
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid1/__init__.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/__init__.py	2010年04月20日 16:43:35 UTC (rev 8245)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid1/__init__.py	2010年04月20日 16:43:42 UTC (rev 8246)
@@ -3,3 +3,5 @@
 make_axes_locatable
 from axes_grid import Grid, ImageGrid, AxesGrid
 #from axes_divider import make_axes_locatable
+
+from parasite_axes import host_subplot, host_axes
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_divider.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_divider.py	2010年04月20日 16:43:35 UTC (rev 8245)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_divider.py	2010年04月20日 16:43:42 UTC (rev 8246)
@@ -501,7 +501,8 @@
 return ax
 
 
- def append_axes(self, position, size, pad=None, **kwargs):
+ def append_axes(self, position, size, pad=None, add_to_figure=True,
+ **kwargs):
 """
 create an axes at the given *position* with the same height
 (or width) of the main axes.
@@ -523,7 +524,8 @@
 else:
 raise ValueError("the position must be one of left, right, bottom, or top")
 
- self._fig.add_axes(ax)
+ if add_to_figure:
+ self._fig.add_axes(ax)
 return ax
 
 def get_aspect(self):
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid1/parasite_axes.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/parasite_axes.py	2010年04月20日 16:43:35 UTC (rev 8245)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid1/parasite_axes.py	2010年04月20日 16:43:42 UTC (rev 8246)
@@ -505,11 +505,30 @@
 return new_class
 
 def host_subplot_class_factory(axes_class):
- host_axes = host_axes_class_factory(axes_class=Axes)
- subplot_host = subplot_class_factory(HostAxes)
- return subplot_host
+ host_axes_class = host_axes_class_factory(axes_class=axes_class)
+ subplot_host_class = subplot_class_factory(host_axes_class)
+ return subplot_host_class
 
 HostAxes = host_axes_class_factory(axes_class=Axes)
 SubplotHost = subplot_class_factory(HostAxes)
 
 
+def host_axes(*args, **kwargs):
+ import matplotlib.pyplot as plt
+ axes_class = kwargs.pop("axes_class", None)
+ host_axes_class = host_axes_class_factory(axes_class)
+ fig = plt.gcf()
+ ax = host_axes_class(fig, *args, **kwargs)
+ fig.add_axes(ax)
+ plt.draw_if_interactive()
+ return ax
+
+def host_subplot(*args, **kwargs):
+ import matplotlib.pyplot as plt
+ axes_class = kwargs.pop("axes_class", None)
+ host_subplot_class = host_subplot_class_factory(axes_class)
+ fig = plt.gcf()
+ ax = host_subplot_class(fig, *args, **kwargs)
+ fig.add_subplot(ax)
+ plt.draw_if_interactive()
+ return ax
Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/__init__.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axisartist/__init__.py	2010年04月20日 16:43:35 UTC (rev 8245)
+++ trunk/matplotlib/lib/mpl_toolkits/axisartist/__init__.py	2010年04月20日 16:43:42 UTC (rev 8246)
@@ -19,3 +19,4 @@
 
 SubplotHost = subplot_class_factory(HostAxes)
 
+
Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/axislines.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axisartist/axislines.py	2010年04月20日 16:43:35 UTC (rev 8245)
+++ trunk/matplotlib/lib/mpl_toolkits/axisartist/axislines.py	2010年04月20日 16:43:42 UTC (rev 8246)
@@ -459,7 +459,7 @@
 offset=None,
 axes=None,
 ):
-
+ 
 if axes is None:
 warnings.warn("'new_fixed_axis' explicitly requires the axes keyword.")
 axes = self.axes
@@ -697,6 +697,17 @@
 self._grid_helper.invalidate()
 
 
+ def new_fixed_axis(self, loc, offset=None):
+ gh = self.get_grid_helper()
+ axis = gh.new_fixed_axis(loc,
+ nth_coord=None,
+ axis_direction=None,
+ offset=offset,
+ axes=self,
+ )
+ return axis
+
+
 def new_floating_axis(self, nth_coord, value,
 axis_direction="bottom",
 ):
@@ -758,7 +769,6 @@
 
 Subplot = maxes.subplot_class_factory(Axes)
 
-
 class AxesZero(Axes):
 def __init__(self, *kl, **kw):
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8245
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8245&view=rev
Author: leejjoon
Date: 2010年04月20日 16:43:35 +0000 (2010年4月20日)
Log Message:
-----------
fix axes_grid1.Grid that wrongly check isinstance instead of issubclass
Modified Paths:
--------------
 trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_grid.py
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_grid.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_grid.py	2010年04月19日 21:02:42 UTC (rev 8244)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_grid.py	2010年04月20日 16:43:35 UTC (rev 8245)
@@ -219,7 +219,7 @@
 axes_class = self._defaultLocatableAxesClass
 axes_class_args = {}
 else:
- if isinstance(axes_class, maxes.Axes):
+ if issubclass(axes_class, maxes.Axes):
 axes_class_args = {}
 else:
 axes_class, axes_class_args = axes_class
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 16 results of 16

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /