SF.net SVN: matplotlib:[7086] trunk/matplotlib

2009-05-06 Thread ryanmay
Revision: 7086
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7086&view=rev
Author:   ryanmay
Date: 2009-05-06 18:13:41 + (Wed, 06 May 2009)

Log Message:
---
Add an example of an updating plot using (multi)processing.  Credit goes to 
Robert Cimrman.

Modified Paths:
--
trunk/matplotlib/CHANGELOG

Added Paths:
---
trunk/matplotlib/examples/misc/log.py

Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG  2009-05-05 17:27:23 UTC (rev 7085)
+++ trunk/matplotlib/CHANGELOG  2009-05-06 18:13:41 UTC (rev 7086)
@@ -1,9 +1,13 @@
 ==
-2009-05-05 Add Axes.get_legend_handles_labels method -JJL
+2009-05-05 Add an example that shows how to make a plot that updates
+   using data from another process.  Thanks to Robert
+   Cimrman - RMM
 
-2009-05-04 Fix bug that Text.Annotation is still drawn while set to 
-   not visible.-JJL
+2009-05-05 Add Axes.get_legend_handles_labels method. - JJL
 
+2009-05-04 Fix bug that Text.Annotation is still drawn while set to
+   not visible. - JJL
+
 2009-05-04 Added TJ's fill_betweenx patch - JDH
 
 2009-05-02 Added options to plotfile based on question from

Added: trunk/matplotlib/examples/misc/log.py
===
--- trunk/matplotlib/examples/misc/log.py   (rev 0)
+++ trunk/matplotlib/examples/misc/log.py   2009-05-06 18:13:41 UTC (rev 
7086)
@@ -0,0 +1,87 @@
+#Demo of using multiprocessing for generating data in one process and plotting
+#in another.
+#Written by Robert Cimrman
+#Requires >= Python 2.6 for the multiprocessing module or having the
+#standalone processing module installed
+import time
+try:
+from multiprocessing import Process, Pipe
+except ImportError:
+from processing import Process, Pipe
+from Queue import Empty
+import numpy as np
+import pylab
+import gobject
+
+class ProcessPlotter(object):
+
+def __init__(self):
+self.x = []
+self.y = []
+
+def terminate(self):
+pylab.close('all')
+
+def poll_draw(self):
+
+def call_back():
+while 1:
+if not self.pipe.poll():
+break
+
+command = self.pipe.recv()
+
+if command is None:
+self.terminate()
+return False
+
+else:
+self.x.append(command[0])
+self.y.append(command[1])
+self.ax.plot(self.x, self.y, 'ro')
+
+self.fig.canvas.draw()
+return True
+
+return call_back
+
+def __call__(self, pipe):
+print 'starting plotter...'
+
+self.pipe = pipe
+self.fig = pylab.figure()
+
+self.ax = self.fig.add_subplot(111)
+self.gid = gobject.timeout_add(1000, self.poll_draw())
+
+print '...done'
+pylab.show()
+
+
+class NBPlot(object):
+def __init__(self):
+self.plot_pipe, plotter_pipe = Pipe()
+self.plotter = ProcessPlotter()
+self.plot_process = Process(target = self.plotter,
+args = (plotter_pipe,))
+self.plot_process.daemon = True
+self.plot_process.start()
+
+def plot(self, finished=False):
+send = self.plot_pipe.send
+if finished:
+send(None)
+else:
+data = np.random.random(2)
+send(data)
+
+def main():
+pl = NBPlot()
+for ii in xrange(10):
+pl.plot()
+time.sleep(0.5)
+raw_input('press Enter...')
+pl.plot(finished=True)
+
+if __name__ == '__main__':
+main()


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[7087] trunk/matplotlib/examples/misc

2009-05-06 Thread efiring
Revision: 7087
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7087&view=rev
Author:   efiring
Date: 2009-05-06 20:52:55 + (Wed, 06 May 2009)

Log Message:
---
Give a more descriptive name (multiprocess.py) to new example

Added Paths:
---
trunk/matplotlib/examples/misc/multiprocess.py

Removed Paths:
-
trunk/matplotlib/examples/misc/log.py

Deleted: trunk/matplotlib/examples/misc/log.py
===
--- trunk/matplotlib/examples/misc/log.py   2009-05-06 18:13:41 UTC (rev 
7086)
+++ trunk/matplotlib/examples/misc/log.py   2009-05-06 20:52:55 UTC (rev 
7087)
@@ -1,87 +0,0 @@
-#Demo of using multiprocessing for generating data in one process and plotting
-#in another.
-#Written by Robert Cimrman
-#Requires >= Python 2.6 for the multiprocessing module or having the
-#standalone processing module installed
-import time
-try:
-from multiprocessing import Process, Pipe
-except ImportError:
-from processing import Process, Pipe
-from Queue import Empty
-import numpy as np
-import pylab
-import gobject
-
-class ProcessPlotter(object):
-
-def __init__(self):
-self.x = []
-self.y = []
-
-def terminate(self):
-pylab.close('all')
-
-def poll_draw(self):
-
-def call_back():
-while 1:
-if not self.pipe.poll():
-break
-
-command = self.pipe.recv()
-
-if command is None:
-self.terminate()
-return False
-
-else:
-self.x.append(command[0])
-self.y.append(command[1])
-self.ax.plot(self.x, self.y, 'ro')
-
-self.fig.canvas.draw()
-return True
-
-return call_back
-
-def __call__(self, pipe):
-print 'starting plotter...'
-
-self.pipe = pipe
-self.fig = pylab.figure()
-
-self.ax = self.fig.add_subplot(111)
-self.gid = gobject.timeout_add(1000, self.poll_draw())
-
-print '...done'
-pylab.show()
-
-
-class NBPlot(object):
-def __init__(self):
-self.plot_pipe, plotter_pipe = Pipe()
-self.plotter = ProcessPlotter()
-self.plot_process = Process(target = self.plotter,
-args = (plotter_pipe,))
-self.plot_process.daemon = True
-self.plot_process.start()
-
-def plot(self, finished=False):
-send = self.plot_pipe.send
-if finished:
-send(None)
-else:
-data = np.random.random(2)
-send(data)
-
-def main():
-pl = NBPlot()
-for ii in xrange(10):
-pl.plot()
-time.sleep(0.5)
-raw_input('press Enter...')
-pl.plot(finished=True)
-
-if __name__ == '__main__':
-main()

Copied: trunk/matplotlib/examples/misc/multiprocess.py (from rev 7086, 
trunk/matplotlib/examples/misc/log.py)
===
--- trunk/matplotlib/examples/misc/multiprocess.py  
(rev 0)
+++ trunk/matplotlib/examples/misc/multiprocess.py  2009-05-06 20:52:55 UTC 
(rev 7087)
@@ -0,0 +1,87 @@
+#Demo of using multiprocessing for generating data in one process and plotting
+#in another.
+#Written by Robert Cimrman
+#Requires >= Python 2.6 for the multiprocessing module or having the
+#standalone processing module installed
+import time
+try:
+from multiprocessing import Process, Pipe
+except ImportError:
+from processing import Process, Pipe
+from Queue import Empty
+import numpy as np
+import pylab
+import gobject
+
+class ProcessPlotter(object):
+
+def __init__(self):
+self.x = []
+self.y = []
+
+def terminate(self):
+pylab.close('all')
+
+def poll_draw(self):
+
+def call_back():
+while 1:
+if not self.pipe.poll():
+break
+
+command = self.pipe.recv()
+
+if command is None:
+self.terminate()
+return False
+
+else:
+self.x.append(command[0])
+self.y.append(command[1])
+self.ax.plot(self.x, self.y, 'ro')
+
+self.fig.canvas.draw()
+return True
+
+return call_back
+
+def __call__(self, pipe):
+print 'starting plotter...'
+
+self.pipe = pipe
+self.fig = pylab.figure()
+
+self.ax = self.fig.add_subplot(111)
+self.gid = gobject.timeout_add(1000, self.poll_draw())
+
+print '...done'
+pylab.show()
+
+
+class NBPlot(object):
+def __init__(self):
+self.plot_pipe, plotter_pipe = Pipe()
+self.plotter = ProcessPlotter()
+self.plot_process = Process(target = self.plotter,
+args = (plotter_pip

SF.net SVN: matplotlib:[7088] trunk/matplotlib/lib/matplotlib/mlab.py

2009-05-06 Thread efiring
Revision: 7088
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7088&view=rev
Author:   efiring
Date: 2009-05-06 23:02:57 + (Wed, 06 May 2009)

Log Message:
---
Spelling correction and other minor cleanups in mlab

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/mlab.py

Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===
--- trunk/matplotlib/lib/matplotlib/mlab.py 2009-05-06 20:52:55 UTC (rev 
7087)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2009-05-06 23:02:57 UTC (rev 
7088)
@@ -175,14 +175,7 @@
 import matplotlib.nxutils as nxutils
 import matplotlib.cbook as cbook
 
-# set is a new builtin function in 2.4; delete the following when
-# support for 2.3 is dropped.
-try:
-set
-except NameError:
-from sets import Set as set
 
-
 def linspace(*args, **kw):
 warnings.warn("use numpy.linspace", DeprecationWarning)
 return np.linspace(*args, **kw)
@@ -617,12 +610,10 @@
 :func:`polyval`
polyval function
 """
-warnings.warn("use numpy.poyfit", DeprecationWarning)
+warnings.warn("use numpy.polyfit", DeprecationWarning)
 return np.polyfit(*args, **kwargs)
 
 
-
-
 def polyval(*args, **kwargs):
 """
 *y* = polyval(*p*, *x*)
@@ -899,14 +890,8 @@
 """
 warnings.warn("Use numpy.trapz(y,x) instead of trapz(x,y)", 
DeprecationWarning)
 return np.trapz(y, x)
-#if len(x)!=len(y):
-#raise ValueError, 'x and y must have the same length'
-#if len(x)<2:
-#raise ValueError, 'x and y must have > 1 element'
-#return np.sum(0.5*np.diff(x)*(y[1:]+y[:-1]))
 
 
-
 def longest_contiguous_ones(x):
 """
 Return the indices of the longest stretch of contiguous ones in *x*,


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[7089] trunk/matplotlib

2009-05-06 Thread leejjoon
Revision: 7089
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7089&view=rev
Author:   leejjoon
Date: 2009-05-07 03:40:40 + (Thu, 07 May 2009)

Log Message:
---
per-artist rasterization

Modified Paths:
--
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/artist.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/axis.py
trunk/matplotlib/lib/matplotlib/collections.py
trunk/matplotlib/lib/matplotlib/figure.py
trunk/matplotlib/lib/matplotlib/image.py
trunk/matplotlib/lib/matplotlib/legend.py
trunk/matplotlib/lib/matplotlib/lines.py
trunk/matplotlib/lib/matplotlib/patches.py
trunk/matplotlib/lib/matplotlib/quiver.py
trunk/matplotlib/lib/matplotlib/table.py

Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG  2009-05-06 23:02:57 UTC (rev 7088)
+++ trunk/matplotlib/CHANGELOG  2009-05-07 03:40:40 UTC (rev 7089)
@@ -1,4 +1,6 @@
 ==
+2009-05-06 Per-artist Rasterization, originally by Eric Bruning. -JJ
+
 2009-05-05 Add an example that shows how to make a plot that updates
using data from another process.  Thanks to Robert
Cimrman - RMM

Modified: trunk/matplotlib/lib/matplotlib/artist.py
===
--- trunk/matplotlib/lib/matplotlib/artist.py   2009-05-06 23:02:57 UTC (rev 
7088)
+++ trunk/matplotlib/lib/matplotlib/artist.py   2009-05-07 03:40:40 UTC (rev 
7089)
@@ -22,6 +22,38 @@
 # 
http://groups.google.com/groups?hl=en&lr=&threadm=mailman.5090.1098044946.5135.python-list%40python.org&rnum=1&prev=/groups%3Fq%3D__doc__%2Bauthor%253Ajdhunter%2540ace.bsd.uchicago.edu%26hl%3Den%26btnG%3DGoogle%2BSearch
 
 
+
+
+def allow_rasterization(draw):
+"""
+Decorator for Artist.draw method. Provides routines
+that run before and after the draw call. The before and after functions
+are useful for changing artist-dependant renderer attributes or making
+other setup function calls, such as starting and flushing a mixed-mode
+renderer. 
+"""
+def before(artist, renderer):
+if artist.get_rasterized():
+renderer.start_rasterizing()
+
+def after(artist, renderer):
+if artist.get_rasterized():
+renderer.stop_rasterizing()
+
+# the axes class has a second argument inframe for its draw method.
+def draw_wrapper(artist, renderer, *kl):
+before(artist, renderer)
+draw(artist, renderer, *kl)
+after(artist, renderer)
+
+# "safe wrapping" to exactly replicate anything we haven't overridden above
+draw_wrapper.__name__ = draw.__name__
+draw_wrapper.__dict__ = draw.__dict__
+draw_wrapper.__doc__  = draw.__doc__
+draw_wrapper._supports_rasterization = True
+return draw_wrapper
+
+
 class Artist(object):
 """
 Abstract base class for someone who renders into a
@@ -45,6 +77,7 @@
 self._label = ''
 self._picker = None
 self._contains = None
+self._rasterized = None
 
 self.eventson = False  # fire events only if eventson
 self._oid = 0  # an observer id
@@ -510,7 +543,23 @@
 else:
 gc.set_clip_rectangle(None)
 gc.set_clip_path(None)
+
+def get_rasterized(self):
+return self._rasterized
+
+def set_rasterized(self, rasterized):
+"""
+Force rasterized (bitmap) drawing in vector backend output.
+
+Defaults to None, which implies the backend's default behavior
+
+ACCEPTS: [True | False | None]
+"""
+if rasterized and not hasattr(self.draw, "_supports_rasterization"):
+warnings.warn("Rasterization of '%s' will be ignored" % self)
 
+self._rasterized = rasterized
+
 def draw(self, renderer, *args, **kwargs):
 'Derived classes drawing method'
 if not self.get_visible(): return

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-05-06 23:02:57 UTC (rev 
7088)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-05-07 03:40:40 UTC (rev 
7089)
@@ -1602,6 +1602,7 @@
 
  Drawing
 
+@allow_rasterization
 def draw(self, renderer=None, inframe=False):
 "Draw everything (plot lines, axes, labels)"
 if renderer is None:

Modified: trunk/matplotlib/lib/matplotlib/axis.py
===
--- trunk/matplotlib/lib/matplotlib/axis.py 2009-05-06 23:02:57 UTC (rev 
7088)
+++ trunk/matplotlib/lib/matplotlib/axis.py 2009-05-07 03:40:40 UTC (rev 
7089)
@@ -5,6 +5,7 @@
 
 from matplotlib  import rcParams
 import matplotlib.artist as artist
+from matplotl

SF.net SVN: matplotlib:[7090] trunk/matplotlib

2009-05-06 Thread leejjoon
Revision: 7090
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7090&view=rev
Author:   leejjoon
Date: 2009-05-07 03:50:55 + (Thu, 07 May 2009)

Log Message:
---
print_ps with mixed-renderer

Modified Paths:
--
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py

Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG  2009-05-07 03:40:40 UTC (rev 7089)
+++ trunk/matplotlib/CHANGELOG  2009-05-07 03:50:55 UTC (rev 7090)
@@ -1,4 +1,8 @@
 ==
+2009-05-06 print_ps now uses mixed-mode renderer. Axes.draw rasterize
+   artists whose zorder smaller than rasterization_zorder.
+   -JJL
+
 2009-05-06 Per-artist Rasterization, originally by Eric Bruning. -JJ
 
 2009-05-05 Add an example that shows how to make a plot that updates

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-05-07 03:40:40 UTC (rev 
7089)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-05-07 03:50:55 UTC (rev 
7090)
@@ -8,6 +8,7 @@
 rcParams = matplotlib.rcParams
 
 import matplotlib.artist as martist
+from matplotlib.artist import allow_rasterization
 import matplotlib.axis as maxis
 import matplotlib.cbook as cbook
 import matplotlib.collections as mcoll
@@ -531,6 +532,8 @@
 self._frameon = frameon
 self._axisbelow = rcParams['axes.axisbelow']
 
+self._rasterization_zorder = -3
+
 self._hold = rcParams['axes.hold']
 self._connected = {} # a dict from events to (id, func)
 self.cla()
@@ -1566,6 +1569,19 @@
 """
 self._autoscaleYon = b
 
+def set_rasterization_zorder(self, z):
+"""
+Set zorder value below which artists will be rasterized
+"""
+self._rasterization_zorder = z
+
+def get_rasterization_zorder(self):
+"""
+Get zorder value below which artists will be rasterized
+"""
+return self._rasterization_zorder 
+
+
 def autoscale_view(self, tight=False, scalex=True, scaley=True):
 """
 autoscale the view limits using the data limits. You can
@@ -1620,15 +1636,55 @@
 else:
 self.apply_aspect()
 
+
+artists = []
+
+artists.extend(self.collections)
+artists.extend(self.patches)
+artists.extend(self.lines)
+artists.extend(self.texts)
+artists.extend(self.artists)
+if self.axison and not inframe:
+if self._axisbelow:
+self.xaxis.set_zorder(0.5)
+self.yaxis.set_zorder(0.5)
+else:
+self.xaxis.set_zorder(2.5)
+self.yaxis.set_zorder(2.5)
+artists.extend([self.xaxis, self.yaxis])
+if not inframe: artists.append(self.title)
+artists.extend(self.tables)
+if self.legend_ is not None:
+artists.append(self.legend_)
+
+# the frame draws the edges around the axes patch -- we
+# decouple these so the patch can be in the background and the
+# frame in the foreground.
+if self.axison and self._frameon:
+artists.append(self.frame)
+
+
+dsu = [ (a.zorder, i, a) for i, a in enumerate(artists)
+if not a.get_animated() ]
+dsu.sort()
+
+
+# rasterze artists with negative zorder
+# if the minimum zorder is negative, start rasterization
+rasterization_zorder = self._rasterization_zorder
+if len(dsu) > 0 and dsu[0][0] < rasterization_zorder:
+renderer.start_rasterizing()
+dsu_rasterized = [l for l in dsu if l[0] < rasterization_zorder]
+dsu = [l for l in dsu if l[0] >= rasterization_zorder]
+else:
+dsu_rasterized = []
+
+
 # the patch draws the background rectangle -- the frame below
 # will draw the edges
 if self.axison and self._frameon:
 self.patch.draw(renderer)
 
-artists = []
-
-
-
 if len(self.images)<=1 or renderer.option_image_nocomposite():
 for im in self.images:
 im.draw(renderer)
@@ -1657,35 +1713,13 @@
 self.patch.get_path(),
 self.patch.get_transform())
 
-artists.extend(self.collections)
-artists.extend(self.patches)
-artists.extend(self.lines)
-artists.extend(self.texts)
-artists.extend(self.artists)
-if self.axison and not inframe:
-if self._axisbelow:
-self.xaxis.set_zorder(0.5)
-self.yaxis.set_zorder(0.5)
-else:
-self

SF.net SVN: matplotlib:[7091] trunk/matplotlib/examples/misc/ rasterization_demo.py

2009-05-06 Thread leejjoon
Revision: 7091
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7091&view=rev
Author:   leejjoon
Date: 2009-05-07 03:51:41 + (Thu, 07 May 2009)

Log Message:
---
added examples/misc/rasterization_demo.py

Added Paths:
---
trunk/matplotlib/examples/misc/rasterization_demo.py

Added: trunk/matplotlib/examples/misc/rasterization_demo.py
===
--- trunk/matplotlib/examples/misc/rasterization_demo.py
(rev 0)
+++ trunk/matplotlib/examples/misc/rasterization_demo.py2009-05-07 
03:51:41 UTC (rev 7091)
@@ -0,0 +1,53 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+d = np.arange(100).reshape(10, 10)
+x, y = np.meshgrid(np.arange(11), np.arange(11))
+
+theta = 0.25*np.pi
+xx = x*np.cos(theta) - y*np.sin(theta)
+yy = x*np.sin(theta) + y*np.cos(theta)
+
+ax1 = plt.subplot(221)
+ax1.set_aspect(1)
+ax1.pcolormesh(xx, yy, d)
+ax1.set_title("No Rasterization")
+
+ax2 = plt.subplot(222)
+ax2.set_aspect(1)
+ax2.set_title("Rasterization")
+
+m = ax2.pcolormesh(xx, yy, d)
+m.set_rasterized(True)
+
+ax3 = plt.subplot(223)
+ax3.set_aspect(1)
+ax3.pcolormesh(xx, yy, d)
+ax3.text(0.5, 0.5, "Text", alpha=0.2,
+ va="center", ha="center", size=50, transform=ax3.transAxes)
+
+ax3.set_title("No Rasterization")
+
+
+ax4 = plt.subplot(224)
+ax4.set_aspect(1)
+m = ax4.pcolormesh(xx, yy, d)
+m.set_zorder(-20)
+
+ax4.text(0.5, 0.5, "Text", alpha=0.2,
+ zorder=-15,
+ va="center", ha="center", size=50, transform=ax4.transAxes)
+
+ax4.set_rasterization_zorder(-10)
+
+ax4.set_title("Rasterization z$<-10$")
+
+
+# ax2.title.set_rasterized(True) # should display a warning
+
+plt.savefig("test_rasterization.pdf", dpi=150)
+plt.savefig("test_rasterization.eps", dpi=150)
+
+if not plt.rcParams["text.usetex"]:
+plt.savefig("test_rasterization.svg", dpi=150)
+# svg backend currently ignores the dpi


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[7092] trunk/matplotlib/doc/users

2009-05-06 Thread leejjoon
Revision: 7092
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7092&view=rev
Author:   leejjoon
Date: 2009-05-07 03:59:28 + (Thu, 07 May 2009)

Log Message:
---
add legend guide in documnetation

Modified Paths:
--
trunk/matplotlib/doc/users/plotting.rst

Added Paths:
---
trunk/matplotlib/doc/users/plotting/
trunk/matplotlib/doc/users/plotting/examples/
trunk/matplotlib/doc/users/plotting/examples/simple_legend01.py
trunk/matplotlib/doc/users/plotting/examples/simple_legend02.py
trunk/matplotlib/doc/users/plotting/legend.rst

Added: trunk/matplotlib/doc/users/plotting/examples/simple_legend01.py
===
--- trunk/matplotlib/doc/users/plotting/examples/simple_legend01.py 
(rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/simple_legend01.py 
2009-05-07 03:59:28 UTC (rev 7092)
@@ -0,0 +1,15 @@
+from matplotlib.pyplot import *
+
+subplot(211)
+plot([1,2,3], label="test1")
+plot([3,2,1], label="test2")
+legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
+   ncol=2, mode="expand", borderaxespad=0.)
+
+subplot(223)
+plot([1,2,3], label="test1")
+plot([3,2,1], label="test2")
+legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
+
+
+show()

Added: trunk/matplotlib/doc/users/plotting/examples/simple_legend02.py
===
--- trunk/matplotlib/doc/users/plotting/examples/simple_legend02.py 
(rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/simple_legend02.py 
2009-05-07 03:59:28 UTC (rev 7092)
@@ -0,0 +1,10 @@
+from matplotlib.pyplot import *
+
+p1, = plot([1,2,3], label="test1")
+p2, = plot([3,2,1], label="test2")
+
+l1 = legend([p1], ["Label 1"], loc=1)
+l2 = legend([p2], ["Label 2"], loc=4) # this removes l1 from the axes.
+gca().add_artist(l1) # add l1 as a separate artist to the axes
+
+show()

Added: trunk/matplotlib/doc/users/plotting/legend.rst
===
--- trunk/matplotlib/doc/users/plotting/legend.rst  
(rev 0)
+++ trunk/matplotlib/doc/users/plotting/legend.rst  2009-05-07 03:59:28 UTC 
(rev 7092)
@@ -0,0 +1,181 @@
+.. _plotting-guide-legend:
+
+
+Legend guide
+
+
+Do not proceed unless you already have read :func:`~matplotlib.pyplot.legend` 
and
+:class:`matplotlib.legend.Legend`!
+
+
+What to be displayed
+
+
+The legend command has a following call signature::
+
+  legend(*args, **kwargs)
+
+If len(args) is 2, the first argument should be a list of artist to be
+labeled, and the second argument should a list of string labels.  If
+len(args) is 0, it automatically generate the legend from label
+properties of the child artists by calling
+:meth:`~matplotlib.axes.Axes.get_legend_handles_labels` method. 
+For example, *ax.legend()* is equivalaent to::
+
+  handles, labels = ax.get_legend_handles_labels()
+  ax.legend(handles, labels)
+
+The :meth:`~matplotlib.axes.Axes.get_legend_handles_labels` method
+returns a tuple of two lists, i.e., list of artists and list of labels
+(python string).  However, it does not return all of its child
+artists. It returns all artists in *ax.lines* and *ax.patches* and
+some artists in *ax.collection* which are instance of
+:class:`~matplotlib.collections.LineCollection` or
+:class:`~matplotlib.collections.RegularPolyCollection`.  The label
+attributes (returned by get_label() method) of collected artists are
+used as text labels. If label attribute is empty string or starts with
+"_", that artist will be ignored.
+
+
+ * Note that not all kind of artists are supported by the legend. The
+   following is the list of artists that are currently supported.
+
+   * :class:`~matplotlib.lines.Line2D`
+   * :class:`~matplotlib.patches.Patch`
+   * :class:`~matplotlib.collections.LineCollection`
+   * :class:`~matplotlib.collections.RegularPolyCollection`
+ 
+   Unfortunately, there is no easy workaround when you need legend for
+   an artist not in the above list (You may use one of the supported
+   artist as a proxy. See below), or customize it beyond what is
+   supported by :class:`matplotlib.legend.Legend`.
+
+ * Remember that some *pyplot* commands return artist not supported by
+   legend, e.g., :func:`~matplotlib.pyplot.fill_between` returns
+   :class:`~matplotlib.collections.PolyCollection` that is not
+   supported. Or some return mupltiple artists. For example,
+   :func:`~matplotlib.pyplot.plot` returns list of
+   :class:`~matplotlib.lines.Line2D` instances, and
+   :func:`~matplotlib.pyplot.errorbar` returns a length 3 tuple of
+   :class:`~matplotlib.lines.Line2D` instances.
+
+ * The legend does not care about the axes that given artists belongs,
+   i.e., the artists may belong to other axes or even none.
+
+
+Adjusting the Order of Legend ite

SF.net SVN: matplotlib:[7093] trunk/matplotlib/doc/users/plotting/legend. rst

2009-05-06 Thread leejjoon
Revision: 7093
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7093&view=rev
Author:   leejjoon
Date: 2009-05-07 04:09:12 + (Thu, 07 May 2009)

Log Message:
---
spelling corrections in legend-guide

Modified Paths:
--
trunk/matplotlib/doc/users/plotting/legend.rst

Modified: trunk/matplotlib/doc/users/plotting/legend.rst
===
--- trunk/matplotlib/doc/users/plotting/legend.rst  2009-05-07 03:59:28 UTC 
(rev 7092)
+++ trunk/matplotlib/doc/users/plotting/legend.rst  2009-05-07 04:09:12 UTC 
(rev 7093)
@@ -20,7 +20,7 @@
 len(args) is 0, it automatically generate the legend from label
 properties of the child artists by calling
 :meth:`~matplotlib.axes.Axes.get_legend_handles_labels` method. 
-For example, *ax.legend()* is equivalaent to::
+For example, *ax.legend()* is equivalent to::
 
   handles, labels = ax.get_legend_handles_labels()
   ax.legend(handles, labels)
@@ -53,7 +53,7 @@
  * Remember that some *pyplot* commands return artist not supported by
legend, e.g., :func:`~matplotlib.pyplot.fill_between` returns
:class:`~matplotlib.collections.PolyCollection` that is not
-   supported. Or some return mupltiple artists. For example,
+   supported. Or some return multiple artists. For example,
:func:`~matplotlib.pyplot.plot` returns list of
:class:`~matplotlib.lines.Line2D` instances, and
:func:`~matplotlib.pyplot.errorbar` returns a length 3 tuple of
@@ -68,7 +68,8 @@
 
 When you want to customize the list of artists to be displayed in the
 legend, or their order of appearance. There are a two options. First,
-you can keep lists of artists and labels, and explicitly use these for the 
first two argument of the legend call.::
+you can keep lists of artists and labels, and explicitly use these for
+the first two argument of the legend call.::
 
   p1, = plot([1,2,3])
   p2, = plot([3,2,1])


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins