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
|
|
From: <dmk...@us...> - 2008-07-18 08:43:07
|
Revision: 5786
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5786&view=rev
Author: dmkaplan
Date: 2008-07-18 08:43:03 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
Making a number of changes related to "blocking" stuff:
1) Adding to cbook.py a method is_sequence_of_strings that is then used in
BlockingInput to test for a tuple-like sequence of event names
2) Modified the use of *fmt* in clabel so that it an also be a
dictionary matching contour levels to arbitrary strings.
3) Removing the extraneous np.array or np.asarray commands in ContourLabeler
as they were forcing linecontour to array, but linecontour should already
be an array.
4) In blocking_input.py replacing all print commands with calls to
matplotlib.verbose.report
5) Removing extra cleanup call from BlockingInput as finally is always
executed, regardless of exception status.
6) Removing what appears to be a "patch" command screwup - there were two
versions of several of the Blocking* classes in blocking_input.py
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/blocking_input.py
trunk/matplotlib/lib/matplotlib/cbook.py
trunk/matplotlib/lib/matplotlib/contour.py
trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/lib/matplotlib/blocking_input.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/blocking_input.py 2008-07-17 21:06:17 UTC (rev 5785)
+++ trunk/matplotlib/lib/matplotlib/blocking_input.py 2008-07-18 08:43:03 UTC (rev 5786)
@@ -19,7 +19,8 @@
import time
import numpy as np
-import matplotlib.path as path
+from matplotlib import path, verbose
+from cbook import is_sequence_of_strings
class BlockingInput(object):
"""
@@ -28,7 +29,7 @@
"""
def __init__(self, fig, eventslist=()):
self.fig = fig
- assert isinstance(eventslist, tuple), "Requires a tuple of event name strings"
+ assert is_sequence_of_strings(eventslist), "Requires a sequence of event name strings"
self.eventslist = eventslist
def on_event(self, event):
@@ -41,8 +42,7 @@
# subclasses
self.add_event(event)
- if self.verbose:
- print "Event %i" % len(self.events)
+ verbose.report("Event %i" % len(self.events))
# This will extract info from events
self.post_event()
@@ -80,7 +80,7 @@
self.pop_event(index)
pop.__doc__=pop_event.__doc__
- def __call__(self, n=1, timeout=30, verbose=False ):
+ def __call__(self, n=1, timeout=30 ):
"""
Blocking call to retrieve n events
"""
@@ -90,7 +90,6 @@
self.events = []
self.done = False
- self.verbose = verbose
self.callbacks = []
# Ensure that the figure is shown
@@ -112,12 +111,10 @@
if timeout > 0 and counter > timeout/0.01:
print "Timeout reached";
break;
- finally: # Activated on exception like ctrl-c
+ finally: # Run even on exception like ctrl-c
+ # Disconnect the callbacks
self.cleanup()
- # Disconnect the callbacks
- self.cleanup()
-
# Return the events in this case
return self.events
@@ -196,10 +193,10 @@
This add the coordinates of an event to the list of clicks
"""
self.clicks.append((event.xdata,event.ydata))
- if self.verbose:
- print "input %i: %f,%f" % (len(self.clicks),
- event.xdata, event.ydata)
+ verbose.report("input %i: %f,%f" %
+ (len(self.clicks),event.xdata, event.ydata))
+
# If desired plot up click
if self.show_clicks:
self.marks.extend(
@@ -238,7 +235,7 @@
# Call base class to remove callbacks
BlockingInput.cleanup(self)
- def __call__(self, n=1, timeout=30, verbose=False, show_clicks=True):
+ def __call__(self, n=1, timeout=30, show_clicks=True):
"""
Blocking call to retrieve n coordinate pairs through mouse
clicks.
@@ -246,7 +243,7 @@
self.show_clicks = show_clicks
self.clicks = []
self.marks = []
- BlockingInput.__call__(self,n=n,timeout=timeout,verbose=verbose)
+ BlockingInput.__call__(self,n=n,timeout=timeout)
return self.clicks
@@ -324,7 +321,7 @@
def __call__(self,inline,n=-1,timeout=-1):
self.inline=inline
- BlockingMouseInput.__call__(self,n=n,timeout=timeout,verbose=False,
+ BlockingMouseInput.__call__(self,n=n,timeout=timeout,
show_clicks=False)
class BlockingKeyMouseInput(BlockingInput):
@@ -343,198 +340,13 @@
self.keyormouse = self.events[-1].name == 'key_press_event'
- def __call__(self, timeout=30, verbose=False):
+ def __call__(self, timeout=30):
"""
Blocking call to retrieve a single mouse or key click
Returns True if key click, False if mouse, or None if timeout
"""
self.keyormouse = None
- BlockingInput.__call__(self,n=1,timeout=timeout,verbose=verbose)
+ BlockingInput.__call__(self,n=1,timeout=timeout)
return self.keyormouse
-"""
-This provides several classes used for interaction with figure windows:
-
-:class:`BlockingInput`
- creates a callable object to retrieve events in a blocking way for interactive sessions
-
-:class:`BlockingKeyMouseInput`
- creates a callable object to retrieve key or mouse clicks in a blocking way for interactive sessions.
- Note: Subclass of BlockingInput. Used by waitforbuttonpress
-
-:class:`BlockingMouseInput`
- creates a callable object to retrieve mouse clicks in a blocking way for interactive sessions.
- Note: Subclass of BlockingInput. Used by ginput
-"""
-
-import time
-
-class BlockingInput(object):
- """
- Class that creates a callable object to retrieve events in a
- blocking way.
- """
- def __init__(self, fig, eventslist=()):
- self.fig = fig
- assert isinstance(eventslist, tuple), \
- "Requires a tuple of event name strings"
- self.eventslist = eventslist
-
- def on_event(self, event):
- """
- Event handler that will be passed to the current figure to
- retrieve events.
- """
- self.events.append(event)
-
- if self.verbose:
- print "Event %i" % len(self.events)
-
- # This will extract info from events
- self.post_event()
-
- if len(self.events) >= self.n and self.n > 0:
- self.done = True
-
- def post_event(self):
- """For baseclass, do nothing but collect events"""
- pass
-
- def cleanup(self):
- """Remove callbacks"""
- for cb in self.callbacks:
- self.fig.canvas.mpl_disconnect(cb)
-
- self.callbacks=[]
-
- def __call__(self, n=1, timeout=30, verbose=False ):
- """
- Blocking call to retrieve n events
- """
-
- assert isinstance(n, int), "Requires an integer argument"
- self.n = n
-
- self.events = []
- self.done = False
- self.verbose = verbose
- self.callbacks = []
-
- # Ensure that the figure is shown
- self.fig.show()
-
- # connect the events to the on_event function call
- for n in self.eventslist:
- self.callbacks.append( self.fig.canvas.mpl_connect(n, self.on_event) )
-
- try:
- # wait for n clicks
- counter = 0
- while not self.done:
- self.fig.canvas.flush_events()
- time.sleep(0.01)
-
- # check for a timeout
- counter += 1
- if timeout > 0 and counter > timeout/0.01:
- print "Timeout reached";
- break;
- finally: # Activated on exception like ctrl-c
- self.cleanup()
-
- # Disconnect the callbacks
- self.cleanup()
-
- # Return the events in this case
- return self.events
-
-class BlockingMouseInput(BlockingInput):
- """
- Class that creates a callable object to retrieve mouse clicks in a
- blocking way.
- """
- def __init__(self, fig):
- BlockingInput.__init__(self, fig=fig, eventslist=('button_press_event',) )
-
- def post_event(self):
- """
- This will be called to process events
- """
- assert len(self.events)>0, "No events yet"
-
- event = self.events[-1]
-
- if event.button == 3:
- # If it's a right click, pop the last coordinates.
- if len(self.clicks) > 0:
- self.clicks.pop()
- del self.events[-2:] # Remove button=3 event and previous event
-
- if self.show_clicks:
- mark = self.marks.pop()
- mark.remove()
- self.fig.canvas.draw()
- elif event.button == 2 and self.n < 0:
- # If it's a middle click, and we are in infinite mode, finish
- self.done = True
- elif event.inaxes:
- # If it's a valid click, append the coordinates to the list
- self.clicks.append((event.xdata, event.ydata))
- if self.verbose:
- print "input %i: %f,%f" % (len(self.clicks),
- event.xdata, event.ydata)
- if self.show_clicks:
- self.marks.extend(
- event.inaxes.plot([event.xdata,], [event.ydata,], 'r+') )
- self.fig.canvas.draw()
-
- def cleanup(self):
- # clean the figure
- if self.show_clicks:
- for mark in self.marks:
- mark.remove()
- self.marks = []
- self.fig.canvas.draw()
-
- # Call base class to remove callbacks
- BlockingInput.cleanup(self)
-
- def __call__(self, n=1, timeout=30, verbose=False, show_clicks=True):
- """
- Blocking call to retrieve n coordinate pairs through mouse
- clicks.
- """
- self.show_clicks = show_clicks
- self.clicks = []
- self.marks = []
- BlockingInput.__call__(self,n=n,timeout=timeout,verbose=verbose)
-
- return self.clicks
-
-class BlockingKeyMouseInput(BlockingInput):
- """
- Class that creates a callable object to retrieve a single mouse or
- keyboard click
- """
- def __init__(self, fig):
- BlockingInput.__init__(self, fig=fig, eventslist=('button_press_event','key_press_event') )
-
- def post_event(self):
- """
- Determines if it is a key event
- """
- assert len(self.events)>0, "No events yet"
-
- self.keyormouse = self.events[-1].name == 'key_press_event'
-
- def __call__(self, timeout=30, verbose=False):
- """
- Blocking call to retrieve a single mouse or key click
- Returns True if key click, False if mouse, or None if timeout
- """
- self.keyormouse = None
- BlockingInput.__call__(self,n=1,timeout=timeout,verbose=verbose)
-
- return self.keyormouse
-
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2008-07-17 21:06:17 UTC (rev 5785)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-07-18 08:43:03 UTC (rev 5786)
@@ -270,6 +270,15 @@
except (TypeError, ValueError): return 0
return 1
+def is_sequence_of_strings(obj):
+ """
+ Returns true if *obj* is iterable and contains strings
+ """
+ if not iterable(obj): return False
+ for o in obj:
+ if not is_string_like(o): return False
+ return True
+
def is_writable_file_like(obj):
'return true if *obj* looks like a file object with a *write* method'
return hasattr(obj, 'write') and callable(obj.write)
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py 2008-07-17 21:06:17 UTC (rev 5785)
+++ trunk/matplotlib/lib/matplotlib/contour.py 2008-07-18 08:43:03 UTC (rev 5786)
@@ -71,6 +71,9 @@
*fmt*:
a format string for the label. Default is '%1.3f'
+ Alternatively, this can be a dictionary matching contour
+ levels with arbitrary strings to use for each contour level
+ (i.e., fmt[level]=string)
*manual*:
if *True*, contour labels will be placed manually using
@@ -158,10 +161,10 @@
if lcsize > 10 * labelwidth:
return 1
- xmax = np.amax(np.array(linecontour)[:,0])
- xmin = np.amin(np.array(linecontour)[:,0])
- ymax = np.amax(np.array(linecontour)[:,1])
- ymin = np.amin(np.array(linecontour)[:,1])
+ xmax = np.amax(linecontour[:,0])
+ xmin = np.amin(linecontour[:,0])
+ ymax = np.amax(linecontour[:,1])
+ ymin = np.amin(linecontour[:,1])
lw = labelwidth
if (xmax - xmin) > 1.2* lw or (ymax - ymin) > 1.2 * lw:
@@ -210,7 +213,7 @@
if cbook.is_string_like(lev):
lw = (len(lev)) * fsize
else:
- lw = (len(fmt%lev)) * fsize
+ lw = (len(self.get_text(lev,fmt))) * fsize
return lw
@@ -227,9 +230,11 @@
if cbook.is_string_like(lev):
return lev
else:
- return fmt%lev
+ if isinstance(fmt,dict):
+ return fmt[lev]
+ else:
+ return fmt%lev
-
def break_linecontour(self, linecontour, rot, labelwidth, ind):
"break a contour in two contours at the location of the label"
lcsize = len(linecontour)
@@ -243,8 +248,8 @@
slc = trans.transform(linecontour)
x,y = slc[ind]
- xx= np.asarray(slc)[:,0].copy()
- yy=np.asarray(slc)[:,1].copy()
+ xx=slc[:,0].copy()
+ yy=slc[:,1].copy()
#indices which are under the label
inds, = np.nonzero(((xx < x+xlabel) & (xx > x-xlabel)) &
@@ -325,8 +330,8 @@
else:
ysize = labelwidth
- XX = np.resize(np.asarray(linecontour)[:,0],(xsize, ysize))
- YY = np.resize(np.asarray(linecontour)[:,1],(xsize, ysize))
+ XX = np.resize(linecontour[:,0],(xsize, ysize))
+ YY = np.resize(linecontour[:,1],(xsize, ysize))
#I might have fouled up the following:
yfirst = YY[:,0].reshape(xsize, 1)
ylast = YY[:,-1].reshape(xsize, 1)
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2008-07-17 21:06:17 UTC (rev 5785)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2008-07-18 08:43:03 UTC (rev 5786)
@@ -1017,11 +1017,11 @@
ax.update_params()
ax.set_position(ax.figbox)
- def ginput(self, n=1, timeout=30, verbose=False, show_clicks=True):
+ def ginput(self, n=1, timeout=30, show_clicks=True):
"""
call signature::
- ginput(self, n=1, timeout=30, verbose=False, show_clicks=True)
+ ginput(self, n=1, timeout=30, show_clicks=True)
Blocking call to interact with the figure.
@@ -1038,7 +1038,7 @@
blocking_mouse_input = BlockingMouseInput(self)
return blocking_mouse_input(n=n, timeout=timeout,
- verbose=verbose, show_clicks=show_clicks)
+ show_clicks=show_clicks)
def waitforbuttonpress(self, timeout=-1):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-17 21:06:22
|
Revision: 5785
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5785&view=rev
Author: jdh2358
Date: 2008-07-17 21:06:17 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
removed screen noise comments from gtkagg and image since I no longer consider this to be a bug
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py
trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py 2008-07-17 20:51:38 UTC (rev 5784)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py 2008-07-17 21:06:17 UTC (rev 5785)
@@ -81,13 +81,6 @@
w = int(ren.width)
h = int(ren.height)
- # There apparently is a bug here on some versions of pygtk
- # (2.6) that crops up in corner cases. Eg, in
- # figimage_demo.py, there is background pixel noise because
- # the figure frame is off and the blended image background has
- # alpha 0. and you see the uninitialzed data ("screen noise").
- # If in _image.cpp Image:from_image you fill the background
- # with a non transparent value, it goes away.
pixbuf = gtk.gdk.pixbuf_new_from_data(
buf, gtk.gdk.COLORSPACE_RGB, True, 8, w, h, w*4)
pixmap.draw_pixbuf(pixmap.new_gc(), pixbuf, 0, 0, 0, 0, w, h,
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp 2008-07-17 20:51:38 UTC (rev 5784)
+++ trunk/matplotlib/src/_image.cpp 2008-07-17 21:06:17 UTC (rev 5785)
@@ -743,9 +743,6 @@
renderer_base rb(pixf);
- //clear the background of the rendering buffer with alpha 1 and the
- //gtkagg screen noise problem in figimage_demo.py goes away -- see
- //comment backend_gtkagg.py _render_figure method JDH
rb.clear(agg::rgba(1, 1, 1, 1));
for (size_t imnum=0; imnum< N; imnum++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-17 20:51:40
|
Revision: 5784
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5784&view=rev
Author: jdh2358
Date: 2008-07-17 20:51:38 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
committed vineet's autodateformatter tz patch
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-07-17 19:38:32 UTC (rev 5783)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-07-17 20:51:38 UTC (rev 5784)
@@ -2095,7 +2095,7 @@
formatter = self.xaxis.get_major_formatter()
if not isinstance(formatter, mdates.DateFormatter):
- formatter = mdates.AutoDateFormatter(locator)
+ formatter = mdates.AutoDateFormatter(locator, tz)
self.xaxis.set_major_formatter(formatter)
def yaxis_date(self, tz=None):
@@ -2132,7 +2132,7 @@
formatter = self.xaxis.get_major_formatter()
if not isinstance(formatter, mdates.DateFormatter):
- formatter = mdates.AutoDateFormatter(locator)
+ formatter = mdates.AutoDateFormatter(locator, tz)
self.yaxis.set_major_formatter(formatter)
def format_xdata(self, x):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-17 19:38:56
|
Revision: 5783
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5783&view=rev
Author: jdh2358
Date: 2008-07-17 19:38:32 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
added Michael's dolphin patch
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/dolphin.py
Added: trunk/matplotlib/examples/pylab_examples/dolphin.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/dolphin.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/dolphin.py 2008-07-17 19:38:32 UTC (rev 5783)
@@ -0,0 +1,83 @@
+import matplotlib.pyplot as plt
+from matplotlib.patches import Circle, PathPatch
+from matplotlib.path import Path
+from matplotlib.transforms import Affine2D
+import numpy as np
+
+r = np.random.rand(50)
+t = np.random.rand(50) * np.pi * 2.0
+x = r * np.cos(t)
+y = r * np.sin(t)
+
+fig = plt.figure(figsize=(6,6))
+ax = plt.subplot(111)
+circle = Circle((0, 0), 1, facecolor=(0,0,0.8),
+ edgecolor=(0,0.8,0.8), linewidth=3, alpha=0.5)
+ax.add_patch(circle)
+
+plt.plot(x, y, 'o', color=(0.9, 0.9, 1.0), alpha=0.8)
+
+# Dolphin from OpenClipart library by Andy Fitzsimon
+# <cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
+# <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+# <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+# <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+# </cc:License>
+
+dolphin = """
+M -0.59739425,160.18173 C -0.62740401,160.18885 -0.57867129,160.11183
+-0.57867129,160.11183 C -0.57867129,160.11183 -0.5438361,159.89315
+-0.39514638,159.81496 C -0.24645668,159.73678 -0.18316813,159.71981
+-0.18316813,159.71981 C -0.18316813,159.71981 -0.10322971,159.58124
+-0.057804323,159.58725 C -0.029723983,159.58913 -0.061841603,159.60356
+-0.071265813,159.62815 C -0.080250183,159.65325 -0.082918513,159.70554
+-0.061841203,159.71248 C -0.040763903,159.7194 -0.0066711426,159.71091
+0.077336307,159.73612 C 0.16879567,159.76377 0.28380306,159.86448
+0.31516668,159.91533 C 0.3465303,159.96618 0.5011127,160.1771
+0.5011127,160.1771 C 0.63668998,160.19238 0.67763022,160.31259
+0.66556395,160.32668 C 0.65339985,160.34212 0.66350443,160.33642
+0.64907098,160.33088 C 0.63463742,160.32533 0.61309688,160.297
+0.5789627,160.29339 C 0.54348657,160.28968 0.52329693,160.27674
+0.50728856,160.27737 C 0.49060916,160.27795 0.48965803,160.31565
+0.46114204,160.33673 C 0.43329696,160.35786 0.4570711,160.39871
+0.43309565,160.40685 C 0.4105108,160.41442 0.39416631,160.33027
+0.3954995,160.2935 C 0.39683269,160.25672 0.43807996,160.21522
+0.44567915,160.19734 C 0.45327833,160.17946 0.27946869,159.9424
+-0.061852613,159.99845 C -0.083965233,160.0427 -0.26176109,160.06683
+-0.26176109,160.06683 C -0.30127962,160.07028 -0.21167141,160.09731
+-0.24649368,160.1011 C -0.32642366,160.11569 -0.34521187,160.06895
+-0.40622293,160.0819 C -0.467234,160.09485 -0.56738444,160.17461
+-0.59739425,160.18173
+"""
+
+vertices = []
+codes = []
+parts = dolphin.split()
+i = 0
+code_map = {
+ 'M': (Path.MOVETO, 1),
+ 'C': (Path.CURVE4, 3),
+ 'L': (Path.LINETO, 1)
+ }
+
+while i < len(parts):
+ code = parts[i]
+ path_code, npoints = code_map[code]
+ codes.extend([path_code] * npoints)
+ vertices.extend([[float(x) for x in y.split(',')] for y in parts[i+1:i+npoints+1]])
+ i += npoints + 1
+vertices = np.array(vertices, np.float)
+vertices[:,1] -= 160
+
+dolphin_path = Path(vertices, codes)
+dolphin_patch = PathPatch(dolphin_path, facecolor=(0.6, 0.6, 0.6),
+ edgecolor=(0.0, 0.0, 0.0))
+ax.add_patch(dolphin_patch)
+
+vertices = Affine2D().rotate_deg(60).transform(vertices)
+dolphin_path2 = Path(vertices, codes)
+dolphin_patch2 = PathPatch(dolphin_path2, facecolor=(0.5, 0.5, 0.5),
+ edgecolor=(0.0, 0.0, 0.0))
+ax.add_patch(dolphin_patch2)
+
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dmk...@us...> - 2008-07-17 19:21:20
|
Revision: 5782
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5782&view=rev
Author: dmkaplan
Date: 2008-07-17 19:20:32 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Adding more functionality for interacting with figure windows through
mouse clicks and keyboard clicks. This includes adding a
waitforbuttonpress function, as well as manual contour label location
selection for clabel. The underlying Blocking* classes that drive
this interaction have been moved into a separate file
"lib/matplotlib/blocking_input.py". Also added a changelog entry.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/contour.py
trunk/matplotlib/lib/matplotlib/figure.py
trunk/matplotlib/lib/matplotlib/pyplot.py
Added Paths:
-----------
trunk/matplotlib/lib/matplotlib/blocking_input.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-07-17 19:15:58 UTC (rev 5781)
+++ trunk/matplotlib/CHANGELOG 2008-07-17 19:20:32 UTC (rev 5782)
@@ -1,3 +1,6 @@
+2008-07-17 Added ability to manually select contour label locations.
+ Also added a waitforbuttonpress function. - DMK
+
2008-07-17 Fix bug with NaNs at end of path (thanks, Andrew Straw for
the report) - MGD
Added: trunk/matplotlib/lib/matplotlib/blocking_input.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/blocking_input.py (rev 0)
+++ trunk/matplotlib/lib/matplotlib/blocking_input.py 2008-07-17 19:20:32 UTC (rev 5782)
@@ -0,0 +1,540 @@
+"""
+This provides several classes used for blocking interaction with figure windows:
+
+:class:`BlockingInput`
+ creates a callable object to retrieve events in a blocking way for interactive sessions
+
+:class:`BlockingKeyMouseInput`
+ creates a callable object to retrieve key or mouse clicks in a blocking way for interactive sessions.
+ Note: Subclass of BlockingInput. Used by waitforbuttonpress
+
+:class:`BlockingMouseInput`
+ creates a callable object to retrieve mouse clicks in a blocking way for interactive sessions.
+ Note: Subclass of BlockingInput. Used by ginput
+
+:class:`BlockingContourLabeler`
+ creates a callable object to retrieve mouse clicks in a blocking way that will then be used to place labels on a ContourSet
+ Note: Subclass of BlockingMouseInput. Used by clabel
+"""
+
+import time
+import numpy as np
+import matplotlib.path as path
+
+class BlockingInput(object):
+ """
+ Class that creates a callable object to retrieve events in a
+ blocking way.
+ """
+ def __init__(self, fig, eventslist=()):
+ self.fig = fig
+ assert isinstance(eventslist, tuple), "Requires a tuple of event name strings"
+ self.eventslist = eventslist
+
+ def on_event(self, event):
+ """
+ Event handler that will be passed to the current figure to
+ retrieve events.
+ """
+ # Add a new event to list - using a separate function is
+ # overkill for the base class, but this is consistent with
+ # subclasses
+ self.add_event(event)
+
+ if self.verbose:
+ print "Event %i" % len(self.events)
+
+ # This will extract info from events
+ self.post_event()
+
+ # Check if we have enough events already
+ if len(self.events) >= self.n and self.n > 0:
+ self.done = True
+
+ def post_event(self):
+ """For baseclass, do nothing but collect events"""
+ pass
+
+ def cleanup(self):
+ """Disconnect all callbacks"""
+ for cb in self.callbacks:
+ self.fig.canvas.mpl_disconnect(cb)
+
+ self.callbacks=[]
+
+ def add_event(self,event):
+ """For base class, this just appends an event to events."""
+ self.events.append(event)
+
+ def pop_event(self,index=-1):
+ """
+ This removes an event from the event list. Defaults to
+ removing last event, but an index can be supplied. Note that
+ this does not check that there are events, much like the
+ normal pop method. If not events exist, this will throw an
+ exception.
+ """
+ self.events.pop(index)
+
+ def pop(self,index=-1):
+ self.pop_event(index)
+ pop.__doc__=pop_event.__doc__
+
+ def __call__(self, n=1, timeout=30, verbose=False ):
+ """
+ Blocking call to retrieve n events
+ """
+
+ assert isinstance(n, int), "Requires an integer argument"
+ self.n = n
+
+ self.events = []
+ self.done = False
+ self.verbose = verbose
+ self.callbacks = []
+
+ # Ensure that the figure is shown
+ self.fig.show()
+
+ # connect the events to the on_event function call
+ for n in self.eventslist:
+ self.callbacks.append( self.fig.canvas.mpl_connect(n, self.on_event) )
+
+ try:
+ # wait for n clicks
+ counter = 0
+ while not self.done:
+ self.fig.canvas.flush_events()
+ time.sleep(0.01)
+
+ # check for a timeout
+ counter += 1
+ if timeout > 0 and counter > timeout/0.01:
+ print "Timeout reached";
+ break;
+ finally: # Activated on exception like ctrl-c
+ self.cleanup()
+
+ # Disconnect the callbacks
+ self.cleanup()
+
+ # Return the events in this case
+ return self.events
+
+class BlockingMouseInput(BlockingInput):
+ """
+ Class that creates a callable object to retrieve mouse clicks in a
+ blocking way.
+ """
+ def __init__(self, fig):
+ BlockingInput.__init__(self, fig=fig,
+ eventslist=('button_press_event',) )
+
+ def post_event(self):
+ """
+ This will be called to process events
+ """
+ assert len(self.events)>0, "No events yet"
+
+ event = self.events[-1]
+ button = event.button
+
+ # Using additional methods for each button is a bit overkill
+ # for this class, but it allows for easy overloading. Also,
+ # this would make it easy to attach other type of non-mouse
+ # events to these "mouse" actions. For example, the matlab
+ # version of ginput also allows you to add points with
+ # keyboard clicks. This could easily be added to this class
+ # with relatively minor modification to post_event and
+ # __init__.
+ if button == 3:
+ self.button3(event)
+ elif button == 2:
+ self.button2(event)
+ else:
+ self.button1(event)
+
+ def button1( self, event ):
+ """
+ Will be called for any event involving a button other than
+ button 2 or 3. This will add a click if it is inside axes.
+ """
+ if event.inaxes:
+ self.add_click(event)
+ else: # If not a valid click, remove from event list
+ BlockingInput.pop(self)
+
+ def button2( self, event ):
+ """
+ Will be called for any event involving button 2.
+ Button 2 ends blocking input.
+ """
+
+ # Remove last event just for cleanliness
+ BlockingInput.pop(self)
+
+ # This will exit even if not in infinite mode. This is
+ # consistent with matlab and sometimes quite useful, but will
+ # require the user to test how many points were actually
+ # returned before using data.
+ self.done = True
+
+ def button3( self, event ):
+ """
+ Will be called for any event involving button 3.
+ Button 3 removes the last click.
+ """
+ # Remove this last event
+ BlockingInput.pop(self)
+
+ # Now remove any existing clicks if possible
+ if len(self.events)>0:
+ self.pop()
+
+ def add_click(self,event):
+ """
+ This add the coordinates of an event to the list of clicks
+ """
+ self.clicks.append((event.xdata,event.ydata))
+ if self.verbose:
+ print "input %i: %f,%f" % (len(self.clicks),
+ event.xdata, event.ydata)
+
+ # If desired plot up click
+ if self.show_clicks:
+ self.marks.extend(
+ event.inaxes.plot([event.xdata,], [event.ydata,], 'r+') )
+ self.fig.canvas.draw()
+
+ def pop_click(self,index=-1):
+ """
+ This removes a click from the list of clicks. Defaults to
+ removing the last click.
+ """
+ self.clicks.pop(index)
+
+ if self.show_clicks:
+ mark = self.marks.pop(index)
+ mark.remove()
+ self.fig.canvas.draw()
+
+ def pop(self,index=-1):
+ """
+ This removes a click and the associated event from the object.
+ Defaults to removing the last click, but any index can be
+ supplied.
+ """
+ self.pop_click(index)
+ BlockingInput.pop(self,index)
+
+ def cleanup(self):
+ # clean the figure
+ if self.show_clicks:
+ for mark in self.marks:
+ mark.remove()
+ self.marks = []
+ self.fig.canvas.draw()
+
+ # Call base class to remove callbacks
+ BlockingInput.cleanup(self)
+
+ def __call__(self, n=1, timeout=30, verbose=False, show_clicks=True):
+ """
+ Blocking call to retrieve n coordinate pairs through mouse
+ clicks.
+ """
+ self.show_clicks = show_clicks
+ self.clicks = []
+ self.marks = []
+ BlockingInput.__call__(self,n=n,timeout=timeout,verbose=verbose)
+
+ return self.clicks
+
+class BlockingContourLabeler( BlockingMouseInput ):
+ """
+ Class that creates a callable object that uses mouse clicks on a
+ figure window to place contour labels.
+ """
+ def __init__(self,cs):
+ self.cs = cs
+ BlockingMouseInput.__init__(self, fig=cs.ax.figure )
+
+ def button1(self,event):
+ """
+ This will be called if an event involving a button other than
+ 2 or 3 occcurs. This will add a label to a contour.
+ """
+ if event.inaxes == self.cs.ax:
+ conmin,segmin,imin,xmin,ymin = self.cs.find_nearest_contour(
+ event.x, event.y)[:5]
+
+ paths = self.cs.collections[conmin].get_paths()
+ lc = paths[segmin].vertices
+
+ # Figure out label rotation. This is very cludgy.
+ # Ideally, there would be one method in ContourLabeler
+ # that would figure out the best rotation for a label at a
+ # point, but the way automatic label rotation is done is
+ # quite mysterious to me and doesn't seem easy to
+ # generalize to non-automatic label placement. The method
+ # used below is not very robust! It basically looks one
+ # point before and one point after label location on
+ # contour and takes mean of angles of two vectors formed.
+ # This produces "acceptable" results, but not nearly as
+ # nice as automatic method.
+ ll = lc[max(0,imin-1):imin+2] # Get points around point
+ dd = np.diff(ll,axis=0)
+ rotation = np.mean( np.arctan2(dd[:,1], dd[:,0]) ) * 180 / np.pi
+ if rotation > 90:
+ rotation = rotation -180
+ if rotation < -90:
+ rotation = 180 + rotation
+
+ self.cs.add_label(xmin,ymin,rotation,conmin)
+
+ if self.inline:
+ # Get label width for breaking contours
+ lw = self.cs.get_label_width(self.cs.label_levels[conmin],
+ self.cs.fmt,
+ self.cs.fslist[conmin])
+ # Break contour
+ new=self.cs.break_linecontour(lc,rotation,lw,imin)
+ if len(new[0]):
+ paths[segmin] = path.Path(new[0])
+ if len(new[1]):
+ paths.extend([path.Path(new[1])])
+
+ self.fig.canvas.draw()
+ else: # Remove event if not valid
+ BlockingInput.pop(self)
+
+ def button3(self,event):
+ """
+ This will be called if button 3 is clicked. This will remove
+ a label if not in inline mode. Unfortunately, if one is doing
+ inline labels, then there is currently no way to fix the
+ broken contour - once humpty-dumpty is broken, he can't be put
+ back together. In inline mode, this does nothing.
+ """
+ if self.inline:
+ pass
+ else:
+ self.cs.pop_label()
+ self.cs.ax.figure.canvas.draw()
+
+ def __call__(self,inline,n=-1,timeout=-1):
+ self.inline=inline
+ BlockingMouseInput.__call__(self,n=n,timeout=timeout,verbose=False,
+ show_clicks=False)
+
+class BlockingKeyMouseInput(BlockingInput):
+ """
+ Class that creates a callable object to retrieve a single mouse or
+ keyboard click
+ """
+ def __init__(self, fig):
+ BlockingInput.__init__(self, fig=fig, eventslist=('button_press_event','key_press_event') )
+
+ def post_event(self):
+ """
+ Determines if it is a key event
+ """
+ assert len(self.events)>0, "No events yet"
+
+ self.keyormouse = self.events[-1].name == 'key_press_event'
+
+ def __call__(self, timeout=30, verbose=False):
+ """
+ Blocking call to retrieve a single mouse or key click
+ Returns True if key click, False if mouse, or None if timeout
+ """
+ self.keyormouse = None
+ BlockingInput.__call__(self,n=1,timeout=timeout,verbose=verbose)
+
+ return self.keyormouse
+
+"""
+This provides several classes used for interaction with figure windows:
+
+:class:`BlockingInput`
+ creates a callable object to retrieve events in a blocking way for interactive sessions
+
+:class:`BlockingKeyMouseInput`
+ creates a callable object to retrieve key or mouse clicks in a blocking way for interactive sessions.
+ Note: Subclass of BlockingInput. Used by waitforbuttonpress
+
+:class:`BlockingMouseInput`
+ creates a callable object to retrieve mouse clicks in a blocking way for interactive sessions.
+ Note: Subclass of BlockingInput. Used by ginput
+"""
+
+import time
+
+class BlockingInput(object):
+ """
+ Class that creates a callable object to retrieve events in a
+ blocking way.
+ """
+ def __init__(self, fig, eventslist=()):
+ self.fig = fig
+ assert isinstance(eventslist, tuple), \
+ "Requires a tuple of event name strings"
+ self.eventslist = eventslist
+
+ def on_event(self, event):
+ """
+ Event handler that will be passed to the current figure to
+ retrieve events.
+ """
+ self.events.append(event)
+
+ if self.verbose:
+ print "Event %i" % len(self.events)
+
+ # This will extract info from events
+ self.post_event()
+
+ if len(self.events) >= self.n and self.n > 0:
+ self.done = True
+
+ def post_event(self):
+ """For baseclass, do nothing but collect events"""
+ pass
+
+ def cleanup(self):
+ """Remove callbacks"""
+ for cb in self.callbacks:
+ self.fig.canvas.mpl_disconnect(cb)
+
+ self.callbacks=[]
+
+ def __call__(self, n=1, timeout=30, verbose=False ):
+ """
+ Blocking call to retrieve n events
+ """
+
+ assert isinstance(n, int), "Requires an integer argument"
+ self.n = n
+
+ self.events = []
+ self.done = False
+ self.verbose = verbose
+ self.callbacks = []
+
+ # Ensure that the figure is shown
+ self.fig.show()
+
+ # connect the events to the on_event function call
+ for n in self.eventslist:
+ self.callbacks.append( self.fig.canvas.mpl_connect(n, self.on_event) )
+
+ try:
+ # wait for n clicks
+ counter = 0
+ while not self.done:
+ self.fig.canvas.flush_events()
+ time.sleep(0.01)
+
+ # check for a timeout
+ counter += 1
+ if timeout > 0 and counter > timeout/0.01:
+ print "Timeout reached";
+ break;
+ finally: # Activated on exception like ctrl-c
+ self.cleanup()
+
+ # Disconnect the callbacks
+ self.cleanup()
+
+ # Return the events in this case
+ return self.events
+
+class BlockingMouseInput(BlockingInput):
+ """
+ Class that creates a callable object to retrieve mouse clicks in a
+ blocking way.
+ """
+ def __init__(self, fig):
+ BlockingInput.__init__(self, fig=fig, eventslist=('button_press_event',) )
+
+ def post_event(self):
+ """
+ This will be called to process events
+ """
+ assert len(self.events)>0, "No events yet"
+
+ event = self.events[-1]
+
+ if event.button == 3:
+ # If it's a right click, pop the last coordinates.
+ if len(self.clicks) > 0:
+ self.clicks.pop()
+ del self.events[-2:] # Remove button=3 event and previous event
+
+ if self.show_clicks:
+ mark = self.marks.pop()
+ mark.remove()
+ self.fig.canvas.draw()
+ elif event.button == 2 and self.n < 0:
+ # If it's a middle click, and we are in infinite mode, finish
+ self.done = True
+ elif event.inaxes:
+ # If it's a valid click, append the coordinates to the list
+ self.clicks.append((event.xdata, event.ydata))
+ if self.verbose:
+ print "input %i: %f,%f" % (len(self.clicks),
+ event.xdata, event.ydata)
+ if self.show_clicks:
+ self.marks.extend(
+ event.inaxes.plot([event.xdata,], [event.ydata,], 'r+') )
+ self.fig.canvas.draw()
+
+ def cleanup(self):
+ # clean the figure
+ if self.show_clicks:
+ for mark in self.marks:
+ mark.remove()
+ self.marks = []
+ self.fig.canvas.draw()
+
+ # Call base class to remove callbacks
+ BlockingInput.cleanup(self)
+
+ def __call__(self, n=1, timeout=30, verbose=False, show_clicks=True):
+ """
+ Blocking call to retrieve n coordinate pairs through mouse
+ clicks.
+ """
+ self.show_clicks = show_clicks
+ self.clicks = []
+ self.marks = []
+ BlockingInput.__call__(self,n=n,timeout=timeout,verbose=verbose)
+
+ return self.clicks
+
+class BlockingKeyMouseInput(BlockingInput):
+ """
+ Class that creates a callable object to retrieve a single mouse or
+ keyboard click
+ """
+ def __init__(self, fig):
+ BlockingInput.__init__(self, fig=fig, eventslist=('button_press_event','key_press_event') )
+
+ def post_event(self):
+ """
+ Determines if it is a key event
+ """
+ assert len(self.events)>0, "No events yet"
+
+ self.keyormouse = self.events[-1].name == 'key_press_event'
+
+ def __call__(self, timeout=30, verbose=False):
+ """
+ Blocking call to retrieve a single mouse or key click
+ Returns True if key click, False if mouse, or None if timeout
+ """
+ self.keyormouse = None
+ BlockingInput.__call__(self,n=1,timeout=timeout,verbose=verbose)
+
+ return self.keyormouse
+
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py 2008-07-17 19:15:58 UTC (rev 5781)
+++ trunk/matplotlib/lib/matplotlib/contour.py 2008-07-17 19:20:32 UTC (rev 5782)
@@ -17,6 +17,9 @@
import matplotlib.text as text
import matplotlib.cbook as cbook
+# Import needed for adding manual selection capability to clabel
+from matplotlib.blocking_input import BlockingContourLabeler
+
# We can't use a single line collection for contour because a line
# collection can have only a single line style, and we want to be able to have
# dashed negative contours, for example, and solid positive contours.
@@ -69,6 +72,13 @@
*fmt*:
a format string for the label. Default is '%1.3f'
+ *manual*:
+ if *True*, contour labels will be placed manually using
+ mouse clicks. Click the first button near a contour to
+ add a label, click the second button (or potentially both
+ mouse buttons at once) to finish adding labels. The third
+ button can be used to remove the last label added, but
+ only if labels are not inline.
"""
fontsize = kwargs.get('fontsize', None)
@@ -76,8 +86,9 @@
self.fmt = kwargs.get('fmt', '%1.3f')
_colors = kwargs.get('colors', None)
+ # Detect if manual selection is desired and remove from argument list
+ self.manual_select=kwargs.get('manual',False)
-
if len(args) == 0:
levels = self.levels
indices = range(len(self.levels))
@@ -126,10 +137,16 @@
#self.cl_cvalues = [] # same
self.cl_xy = []
- self.labels(inline)
+ if self.manual_select:
+ print 'Select label locations manually using first mouse button.'
+ print 'End manual selection with second mouse button.'
+ if not inline:
+ print 'Remove last label by clicking third mouse button.'
- for label in self.cl:
- self.ax.add_artist(label)
+ blocking_contour_labeler = BlockingContourLabeler(self)
+ blocking_contour_labeler(inline)
+ else:
+ self.labels(inline)
self.label_list = cbook.silent_list('text.Text', self.cl)
return self.label_list
@@ -335,19 +352,85 @@
return x,y, rotation, dind
+ def add_label(self,x,y,rotation,icon):
+ dx,dy = self.ax.transData.inverted().transform_point((x,y))
+ t = text.Text(dx, dy, rotation = rotation,
+ horizontalalignment='center',
+ verticalalignment='center')
+
+ color = self.label_mappable.to_rgba(self.label_cvalues[icon],
+ alpha=self.alpha)
+
+ _text = self.get_text(self.label_levels[icon],self.fmt)
+ self.set_label_props(t, _text, color)
+ self.cl.append(t)
+ self.cl_cvalues.append(self.label_cvalues[icon])
+
+ # Add label to plot here - useful for manual mode label selection
+ self.ax.add_artist(t)
+
+ def pop_label(self,index=-1):
+ '''Defaults to removing last label, but any index can be supplied'''
+ self.cl_cvalues.pop(index)
+ t = self.cl.pop(index)
+ t.remove()
+
+ def find_nearest_contour( self, x, y, pixel=True ):
+ """
+ Finds contour that is closest to a point. Defaults to
+ measuring distance in pixels (screen space - useful for manual
+ contour labeling), but this can be controlled via a keyword
+ argument.
+
+ Returns a tuple containing the contour, segment, index of
+ segment, x & y of segment point and distance to minimum point.
+ """
+
+ # This function uses a method that is probably quite
+ # inefficient based on converting each contour segment to
+ # pixel coordinates and then comparing the given point to
+ # those coordinates for each contour. This will probably be
+ # quite slow for complex contours, but for normal use it works
+ # sufficiently well that the time is not noticeable.
+ # Nonetheless, improvements could probably be made.
+
+ dmin = 1e10
+ conmin = None
+ segmin = None
+ xmin = None
+ ymin = None
+
+ for icon in self.label_indices:
+ con = self.collections[icon]
+ paths = con.get_paths()
+ for segNum, linepath in enumerate(paths):
+ lc = linepath.vertices
+
+ # transfer all data points to screen coordinates if desired
+ if pixel:
+ lc = self.ax.transData.transform(lc)
+
+ ds = (lc[:,0]-x)**2 + (lc[:,1]-y)**2
+ d = min( ds )
+ if d < dmin:
+ dmin = d
+ conmin = icon
+ segmin = segNum
+ imin = mpl.mlab.find( ds == d )[0]
+ xmin = lc[imin,0]
+ ymin = lc[imin,1]
+
+ return (conmin,segmin,imin,xmin,ymin,dmin)
+
def labels(self, inline):
levels = self.label_levels
fslist = self.fslist
trans = self.ax.transData
- _colors = self.label_mappable.to_rgba(self.label_cvalues,
- alpha=self.alpha)
- fmt = self.fmt
- for icon, lev, color, cvalue, fsize in zip(self.label_indices,
- self.label_levels,
- _colors,
- self.label_cvalues, fslist):
+
+ for icon, lev, fsize in zip(self.label_indices,
+ self.label_levels, fslist):
con = self.collections[icon]
- lw = self.get_label_width(lev, fmt, fsize)
+ lw = self.get_label_width(lev, self.fmt, fsize)
additions = []
paths = con.get_paths()
for segNum, linepath in enumerate(paths):
@@ -362,16 +445,8 @@
slc = trans.transform(linecontour)
if self.print_label(slc,lw):
x,y, rotation, ind = self.locate_label(slc, lw)
- # transfer the location of the label back to
- # data coordinates
- dx,dy = trans.inverted().transform_point((x,y))
- t = text.Text(dx, dy, rotation = rotation,
- horizontalalignment='center',
- verticalalignment='center')
- _text = self.get_text(lev,fmt)
- self.set_label_props(t, _text, color)
- self.cl.append(t)
- self.cl_cvalues.append(cvalue)
+ self.add_label(x,y,rotation,icon)
+
if inline:
new = self.break_linecontour(linecontour, rotation, lw, ind)
if len(new[0]):
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2008-07-17 19:15:58 UTC (rev 5781)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2008-07-17 19:20:32 UTC (rev 5782)
@@ -6,9 +6,6 @@
:class:`SubplotParams`
control the default spacing of the subplots
-:class:`BlockingMouseInput`
- creates a callable object to retrieve mouse clicks in a blocking way for interactive sessions
-
:class:`Figure`
top level container for all plot elements
@@ -32,6 +29,7 @@
from transforms import Affine2D, Bbox, BboxTransformTo, TransformedBbox
from projections import projection_factory, get_projection_names, \
get_projection_class
+from matplotlib.blocking_input import BlockingMouseInput, BlockingKeyMouseInput
import matplotlib.cbook as cbook
@@ -117,87 +115,6 @@
setattr(self, s, val)
-
-class BlockingMouseInput(object):
- """
- Class that creates a callable object to retrieve mouse clicks in a
- blocking way.
- """
- def __init__(self, fig):
- self.fig = fig
-
-
- def on_click(self, event):
- """
- Event handler that will be passed to the current figure to
- retrieve clicks.
- """
- if event.button == 3:
- # If it's a right click, pop the last coordinates.
- if len(self.clicks) > 0:
- self.clicks.pop()
- if self.show_clicks:
- mark = self.marks.pop()
- mark.remove()
- self.fig.canvas.draw()
- elif event.button == 2 and self.n < 0:
- # If it's a middle click, and we are in infinite mode, finish
- self.done = True
- elif event.inaxes:
- # If it's a valid click, append the coordinates to the list
- self.clicks.append((event.xdata, event.ydata))
- if self.verbose:
- print "input %i: %f,%f" % (len(self.clicks),
- event.xdata, event.ydata)
- if self.show_clicks:
- self.marks.extend(
- event.inaxes.plot([event.xdata,], [event.ydata,], 'r+') )
- self.fig.canvas.draw()
- if self.n > 0 and len(self.clicks) >= self.n:
- self.done = True
-
-
- def __call__(self, n=1, timeout=30, verbose=False, show_clicks=True):
- """
- Blocking call to retrieve n coordinate pairs through mouse
- clicks.
- """
- self.verbose = verbose
- self.done = False
- self.clicks = []
- self.show_clicks = True
- self.marks = []
-
- assert isinstance(n, int), "Requires an integer argument"
- self.n = n
-
- # Ensure that the figure is shown
- self.fig.show()
- # connect the click events to the on_click function call
- self.callback = self.fig.canvas.mpl_connect('button_press_event',
- self.on_click)
- # wait for n clicks
- counter = 0
- while not self.done:
- self.fig.canvas.flush_events()
- time.sleep(0.01)
-
- # check for a timeout
- counter += 1
- if timeout > 0 and counter > timeout/0.01:
- print "ginput timeout";
- break;
-
- # Disconnect the event, clean the figure, and return what we have
- self.fig.canvas.mpl_disconnect(self.callback)
- self.callback = None
- if self.show_clicks:
- for mark in self.marks:
- mark.remove()
- self.fig.canvas.draw()
- return self.clicks
-
-
class Figure(Artist):
"""
@@ -1121,10 +1038,27 @@
blocking_mouse_input = BlockingMouseInput(self)
return blocking_mouse_input(n=n, timeout=timeout,
- verbose=verbose, show_clicks=True)
+ verbose=verbose, show_clicks=show_clicks)
+ def waitforbuttonpress(self, timeout=-1):
+ """
+ call signature::
+ waitforbuttonpress(self, timeout=-1)
+ Blocking call to interact with the figure.
+
+ This will return True is a key was pressed, False if a mouse
+ button was pressed and None if *timeout* was reached without
+ either being pressed.
+
+ If *timeout* is negative, does not timeout.
+ """
+
+ blocking_input = BlockingKeyMouseInput(self)
+ return blocking_input(timeout=timeout)
+
+
def figaspect(arg):
"""
Create a figure with specified aspect ratio. If *arg* is a number,
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-07-17 19:15:58 UTC (rev 5781)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-07-17 19:20:32 UTC (rev 5782)
@@ -320,7 +320,21 @@
if Figure.ginput.__doc__ is not None:
ginput.__doc__ = dedent(Figure.ginput.__doc__)
+def waitforbuttonpress(*args, **kwargs):
+ """
+ Blocking call to interact with the figure.
+ This will wait for *n* key or mouse clicks from the user and
+ return a list containing True's for keyboard clicks and False's
+ for mouse clicks.
+
+ If *timeout* is negative, does not timeout.
+ """
+ return gcf().waitforbuttonpress(*args, **kwargs)
+if Figure.waitforbuttonpress.__doc__ is not None:
+ waitforbuttonpress.__doc__ = dedent(Figure.waitforbuttonpress.__doc__)
+
+
# Putting things in figures
def figtext(*args, **kwargs):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-17 19:16:55
|
Revision: 5781
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5781&view=rev
Author: jdh2358
Date: 2008-07-17 19:15:58 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
more fixes for numpy svn deprecation warnings
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/nan_test.py
trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
trunk/matplotlib/lib/matplotlib/__init__.py
trunk/matplotlib/src/_backend_gdk.c
trunk/matplotlib/src/_path.cpp
trunk/matplotlib/src/_png.cpp
trunk/matplotlib/src/cntr.c
trunk/matplotlib/src/nxutils.c
Modified: trunk/matplotlib/examples/pylab_examples/nan_test.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/nan_test.py 2008-07-17 18:56:48 UTC (rev 5780)
+++ trunk/matplotlib/examples/pylab_examples/nan_test.py 2008-07-17 19:15:58 UTC (rev 5781)
@@ -22,8 +22,7 @@
plot(t, s, '-', lw=2)
xlabel('time (s)')
-ylabel('voltage (mV)')
-title('More NaNs at 0.0 and 1.0')
+ylabel('more nans')
grid(True)
show()
Modified: trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py 2008-07-17 18:56:48 UTC (rev 5780)
+++ trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py 2008-07-17 19:15:58 UTC (rev 5781)
@@ -40,6 +40,7 @@
# Or use the default, which is transparent:
col = ax.pcolormesh(Qx,Qz,Zm)
ax.set_title('With masked values')
-show()
+
savefig("quadmesh_demo")
+show()
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2008-07-17 18:56:48 UTC (rev 5780)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-07-17 19:15:58 UTC (rev 5781)
@@ -89,7 +89,7 @@
"""
from __future__ import generators
-__version__ = '0.98.2'
+__version__ = '0.98.3'
__revision__ = '$Revision$'
__date__ = '$Date$'
Modified: trunk/matplotlib/src/_backend_gdk.c
===================================================================
--- trunk/matplotlib/src/_backend_gdk.c 2008-07-17 18:56:48 UTC (rev 5780)
+++ trunk/matplotlib/src/_backend_gdk.c 2008-07-17 19:15:58 UTC (rev 5781)
@@ -28,7 +28,7 @@
PyGObject *py_pixbuf;
GdkPixbuf *gdk_pixbuf;
PyArrayObject *array;
- int dims[3] = { 0, 0, 3 };
+ npy_intp dims[3] = { 0, 0, 3 };
if (!PyArg_ParseTuple(args, "O!:pixbuf_get_pixels_array",
&PyGdkPixbuf_Type, &py_pixbuf))
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-07-17 18:56:48 UTC (rev 5780)
+++ trunk/matplotlib/src/_path.cpp 2008-07-17 19:15:58 UTC (rev 5781)
@@ -846,7 +846,7 @@
::clip_to_rect(path, x0, y0, x1, y1, inside, results);
- int dims[2];
+ npy_intp dims[2];
dims[1] = 2;
PyObject* py_results = PyList_New(results.size());
if (!py_results)
Modified: trunk/matplotlib/src/_png.cpp
===================================================================
--- trunk/matplotlib/src/_png.cpp 2008-07-17 18:56:48 UTC (rev 5780)
+++ trunk/matplotlib/src/_png.cpp 2008-07-17 19:15:58 UTC (rev 5781)
@@ -249,7 +249,7 @@
- int dimensions[3];
+ npy_intp dimensions[3];
dimensions[0] = height; //numrows
dimensions[1] = width; //numcols
dimensions[2] = 4;
Modified: trunk/matplotlib/src/cntr.c
===================================================================
--- trunk/matplotlib/src/cntr.c 2008-07-17 18:56:48 UTC (rev 5780)
+++ trunk/matplotlib/src/cntr.c 2008-07-17 19:15:58 UTC (rev 5781)
@@ -1333,7 +1333,7 @@
{
PyObject *point, *all_contours;
PyArrayObject *xv, *yv;
- int dims[1];
+ npy_intp dims[1];
int i;
long j, k;
@@ -1343,8 +1343,8 @@
for (i = 0; i < nparts; i++)
{
dims[0] = np[i];
- xv = (PyArrayObject *) PyArray_FromDims(1, dims, PyArray_DOUBLE);
- yv = (PyArrayObject *) PyArray_FromDims(1, dims, PyArray_DOUBLE);
+ xv = (PyArrayObject *) PyArray_SimpleNew(1, dims, PyArray_DOUBLE);
+ yv = (PyArrayObject *) PyArray_SimpleNew(1, dims, PyArray_DOUBLE);
if (xv == NULL || yv == NULL) goto error;
for (j = 0; j < dims[0]; j++)
{
@@ -1370,7 +1370,7 @@
{
PyObject *all_contours;
PyArrayObject *xyv;
- int dims[2];
+ npy_intp dims[2];
int i;
long j, k;
@@ -1381,7 +1381,7 @@
{
dims[0] = np[i];
dims[1] = 2;
- xyv = (PyArrayObject *) PyArray_FromDims(2, dims, PyArray_DOUBLE);
+ xyv = (PyArrayObject *) PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
if (xyv == NULL) goto error;
for (j = 0; j < dims[0]; j++)
{
Modified: trunk/matplotlib/src/nxutils.c
===================================================================
--- trunk/matplotlib/src/nxutils.c 2008-07-17 18:56:48 UTC (rev 5780)
+++ trunk/matplotlib/src/nxutils.c 2008-07-17 19:15:58 UTC (rev 5781)
@@ -108,7 +108,7 @@
PyObject *xypointsarg, *vertsarg, *ret;
PyArrayObject *xypoints, *verts;
PyArrayObject *mask;
- int dimensions[1];
+ npy_intp dimensions[1];
if (! PyArg_ParseTuple(args, "OO", &xypointsarg, &vertsarg))
return NULL;
@@ -187,7 +187,7 @@
npoints = xypoints->dimensions[0];
dimensions[0] = npoints;
- mask = (PyArrayObject *)PyArray_FromDims(1,dimensions,PyArray_INT);
+ mask = (PyArrayObject *)PyArray_SimpleNew(1,dimensions,PyArray_INT);
if (mask==NULL) {
Py_XDECREF(verts);
Py_XDECREF(xypoints);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-17 18:57:07
|
Revision: 5780
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5780&view=rev
Author: jdh2358
Date: 2008-07-17 18:56:48 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
some fixes for numpy svn deprecation warnings
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
trunk/matplotlib/lib/mpl_toolkits/exceltools.py
trunk/matplotlib/src/_path.cpp
trunk/matplotlib/src/_png.cpp
trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-07-17 18:27:36 UTC (rev 5779)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-07-17 18:56:48 UTC (rev 5780)
@@ -459,7 +459,8 @@
if Gcf.get_num_fig_managers()==0 and \
not matplotlib.is_interactive() and \
gtk.main_level() >= 1:
- gtk.main_quit()
+ #gtk.main_quit()
+ pass
def show(self):
# show the figure window
Modified: trunk/matplotlib/lib/mpl_toolkits/exceltools.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/exceltools.py 2008-07-17 18:27:36 UTC (rev 5779)
+++ trunk/matplotlib/lib/mpl_toolkits/exceltools.py 2008-07-17 18:56:48 UTC (rev 5780)
@@ -5,7 +5,7 @@
import matplotlib.mlab as mlab
import mpl_toolkits.exceltools as exceltools
-
+
r = mlab.csv2rec('somefile.csv', checkrows=0)
formatd = dict(
@@ -52,7 +52,7 @@
return format
-def rec2excel(r, ws, formatd=None, rownum=0, colnum=0):
+def rec2excel(r, ws, formatd=None, rownum=0, colnum=0, nanstr='NaN'):
"""
save record array r to excel pyExcelerator worksheet ws
starting at rownum. if ws is string like, assume it is a
@@ -62,6 +62,7 @@
formatd is a dictionary mapping dtype name -> mlab.Format instances
+ nanstr is the string that mpl will put into excel for np.nan value
The next rownum after writing is returned
"""
@@ -106,7 +107,7 @@
ws.write(rownum, colnum+i, val)
else:
if mlab.safe_isnan(val):
- ws.write(rownum, colnum+i, 'NaN')
+ ws.write(rownum, colnum+i, nanstr)
else:
ws.write(rownum, colnum+i, val, format.xlstyle)
rownum += 1
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-07-17 18:27:36 UTC (rev 5779)
+++ trunk/matplotlib/src/_path.cpp 2008-07-17 18:56:48 UTC (rev 5780)
@@ -857,7 +857,7 @@
{
size_t size = p->size();
dims[0] = p->size();
- PyArrayObject* pyarray = (PyArrayObject*)PyArray_FromDims(2, dims, PyArray_DOUBLE);
+ PyArrayObject* pyarray = (PyArrayObject*)PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
for (size_t i = 0; i < size; ++i)
{
((double *)pyarray->data)[2*i] = (*p)[i].x;
Modified: trunk/matplotlib/src/_png.cpp
===================================================================
--- trunk/matplotlib/src/_png.cpp 2008-07-17 18:27:36 UTC (rev 5779)
+++ trunk/matplotlib/src/_png.cpp 2008-07-17 18:56:48 UTC (rev 5780)
@@ -254,7 +254,7 @@
dimensions[1] = width; //numcols
dimensions[2] = 4;
- PyArrayObject *A = (PyArrayObject *) PyArray_FromDims(3, dimensions, PyArray_FLOAT);
+ PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(3, dimensions, PyArray_FLOAT);
for (png_uint_32 y = 0; y < height; y++) {
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp 2008-07-17 18:27:36 UTC (rev 5779)
+++ trunk/matplotlib/src/ft2font.cpp 2008-07-17 18:56:48 UTC (rev 5780)
@@ -274,7 +274,7 @@
/*
- PyArrayObject *A = (PyArrayObject *) PyArray_FromDims(2, dimensions, PyArray_UBYTE);
+ PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(2, dimensions, PyArray_UBYTE);
unsigned char *src = _buffer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-17 18:27:41
|
Revision: 5779
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5779&view=rev
Author: mdboom
Date: 2008-07-17 18:27:36 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Minor simplification.
Modified Paths:
--------------
trunk/matplotlib/doc/sphinxext/inheritance_diagram.py
Modified: trunk/matplotlib/doc/sphinxext/inheritance_diagram.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/inheritance_diagram.py 2008-07-17 18:27:00 UTC (rev 5778)
+++ trunk/matplotlib/doc/sphinxext/inheritance_diagram.py 2008-07-17 18:27:36 UTC (rev 5779)
@@ -326,13 +326,10 @@
# Create a mapping from fully-qualified class names to URLs.
urls = {}
for child in node:
- try:
+ if 'refuri' in child:
urls[child['reftitle']] = child['refuri']
- except KeyError:
- try:
- urls[child['reftitle']] = '#' + child['refid']
- except KeyError:
- pass
+ elif 'refid' in child:
+ urls[child['reftitle']] = '#' + child['refid']
# These arguments to dot will save a PNG file to disk and write
# an HTML image map to stdout.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-17 18:27:03
|
Revision: 5778
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5778&view=rev
Author: mdboom
Date: 2008-07-17 18:27:00 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Minor docstring fix.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2008-07-17 18:26:41 UTC (rev 5777)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2008-07-17 18:27:00 UTC (rev 5778)
@@ -929,6 +929,10 @@
def text(self, x, y, s, *args, **kwargs):
"""
+ Call signature:
+
+ figtext(x, y, s, fontdict=None, **kwargs)
+
Add text to figure at location *x*, *y* (relative 0-1
coords). See :func:`~matplotlib.pyplot.text` for the meaning
of the other arguments.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-17 18:26:45
|
Revision: 5777
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5777&view=rev
Author: mdboom
Date: 2008-07-17 18:26:41 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Fix non-linear scaling with pcolormesh and non-Agg backends.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-07-17 18:25:20 UTC (rev 5776)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-07-17 18:26:41 UTC (rev 5777)
@@ -10,6 +10,7 @@
"""
import math, warnings
import numpy as np
+import numpy.ma as ma
import matplotlib as mpl
import matplotlib.cbook as cbook
import matplotlib.colors as _colors # avoid conflict with kwarg
@@ -468,7 +469,11 @@
"""
Path = mpath.Path
- c = coordinates
+ if ma.isMaskedArray(coordinates):
+ c = coordinates.data
+ else:
+ c = coordinates
+
# We could let the Path constructor generate the codes for us,
# but this is faster, since we know they'll always be the same
codes = np.array(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-17 18:25:23
|
Revision: 5776
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5776&view=rev
Author: mdboom
Date: 2008-07-17 18:25:20 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Remove possibility of buffer overrun in last commit.
Modified Paths:
--------------
trunk/matplotlib/src/agg_py_path_iterator.h
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2008-07-17 17:40:47 UTC (rev 5775)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-07-17 18:25:20 UTC (rev 5776)
@@ -75,14 +75,18 @@
{
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
unsigned code = vertex_with_code(m_iterator++, x, y);
+
if (MPL_isnan64(*x) || MPL_isnan64(*y)) {
- do {
- vertex(m_iterator++, x, y);
- } while ((MPL_isnan64(*x) || MPL_isnan64(*y)) &&
- m_iterator < m_total_vertices);
- return (m_iterator >= m_total_vertices) ? agg::path_cmd_stop :
- agg::path_cmd_move_to;
+ do {
+ if (m_iterator < m_total_vertices) {
+ vertex(m_iterator++, x, y);
+ } else {
+ return agg::path_cmd_stop;
+ }
+ } while (MPL_isnan64(*x) || MPL_isnan64(*y));
+ return agg::path_cmd_move_to;
}
+
return code;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-17 17:40:49
|
Revision: 5775
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5775&view=rev
Author: mdboom
Date: 2008-07-17 17:40:47 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Fix problem with NaNs at end of path.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/src/agg_py_path_iterator.h
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-07-17 17:16:12 UTC (rev 5774)
+++ trunk/matplotlib/CHANGELOG 2008-07-17 17:40:47 UTC (rev 5775)
@@ -1,3 +1,6 @@
+2008-07-17 Fix bug with NaNs at end of path (thanks, Andrew Straw for
+ the report) - MGD
+
2008-07-12 Added support for external backends with the
"module://my_backend" syntax - JDH
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2008-07-17 17:16:12 UTC (rev 5774)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-07-17 17:40:47 UTC (rev 5775)
@@ -75,11 +75,13 @@
{
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
unsigned code = vertex_with_code(m_iterator++, x, y);
- while ((MPL_isnan64(*x) || MPL_isnan64(*y)) &&
- m_iterator < m_total_vertices)
- {
+ if (MPL_isnan64(*x) || MPL_isnan64(*y)) {
+ do {
vertex(m_iterator++, x, y);
- code = agg::path_cmd_move_to;
+ } while ((MPL_isnan64(*x) || MPL_isnan64(*y)) &&
+ m_iterator < m_total_vertices);
+ return (m_iterator >= m_total_vertices) ? agg::path_cmd_stop :
+ agg::path_cmd_move_to;
}
return code;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-17 17:16:31
|
Revision: 5774
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5774&view=rev
Author: mdboom
Date: 2008-07-17 17:16:12 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Reverting last (accidental) commit.
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
Modified: trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py 2008-07-17 17:06:52 UTC (rev 5773)
+++ trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py 2008-07-17 17:16:12 UTC (rev 5774)
@@ -29,8 +29,6 @@
ax = fig.add_subplot(121)
ax.set_axis_bgcolor("#bdb76b")
ax.pcolormesh(Qx,Qz,Z)
-ax.set_xscale('log')
-ax.set_yscale('log')
ax.set_title('Without masked values')
ax = fig.add_subplot(122)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2008-07-17 17:07:07
|
Revision: 5773
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5773&view=rev
Author: astraw
Date: 2008-07-17 17:06:52 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
update nan example to demonstrate bug
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/nan_test.py
Modified: trunk/matplotlib/examples/pylab_examples/nan_test.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/nan_test.py 2008-07-17 12:47:22 UTC (rev 5772)
+++ trunk/matplotlib/examples/pylab_examples/nan_test.py 2008-07-17 17:06:52 UTC (rev 5773)
@@ -1,12 +1,14 @@
#!/usr/bin/env python
"""
-Example: simple line plot with NaNs inserted.
+Example: simple line plots with NaNs inserted.
"""
from pylab import *
t = arange(0.0, 1.0+0.01, 0.01)
s = cos(2*2*pi*t)
t[41:60] = NaN
+
+subplot(2,1,1)
plot(t, s, '-', lw=2)
xlabel('time (s)')
@@ -14,4 +16,14 @@
title('A sine wave with a gap of NaNs between 0.4 and 0.6')
grid(True)
+subplot(2,1,2)
+t[0] = NaN
+t[-1] = NaN
+plot(t, s, '-', lw=2)
+
+xlabel('time (s)')
+ylabel('voltage (mV)')
+title('More NaNs at 0.0 and 1.0')
+grid(True)
+
show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-07-17 12:47:44
|
Revision: 5772
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5772&view=rev
Author: dsdale
Date: 2008-07-17 12:47:22 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Merged revisions 5771 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
........
r5771 | dsdale | 2008-07-17 08:01:50 -0400 (Thu, 17 Jul 2008) | 2 lines
improve error reporting in texmanager
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/texmanager.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-5723
+ /branches/v0_91_maint:1-5771
Added: svn:mergeinfo
+ /branches/v0_91_maint:5753-5771
Modified: trunk/matplotlib/lib/matplotlib/texmanager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/texmanager.py 2008-07-17 12:01:50 UTC (rev 5771)
+++ trunk/matplotlib/lib/matplotlib/texmanager.py 2008-07-17 12:47:22 UTC (rev 5772)
@@ -273,16 +273,22 @@
%(os.path.split(texfile)[-1], outfile))
mpl.verbose.report(command, 'debug')
exit_status = os.system(command)
- fh = file(outfile)
+ try:
+ fh = file(outfile)
+ report = fh.read()
+ fh.close()
+ except IOError:
+ report = 'No latex error report available.'
if exit_status:
raise RuntimeError(('LaTeX was not able to process the following \
-string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + fh.read())
- else: mpl.verbose.report(fh.read(), 'debug')
- fh.close()
+string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + report)
+ else: mpl.verbose.report(report, 'debug')
for fname in glob.glob(basefile+'*'):
if fname.endswith('dvi'): pass
elif fname.endswith('tex'): pass
- else: os.remove(fname)
+ else:
+ try: os.remove(fname)
+ except OSError: pass
return dvifile
@@ -305,14 +311,19 @@
os.path.split(dvifile)[-1], outfile))
mpl.verbose.report(command, 'debug')
exit_status = os.system(command)
- fh = file(outfile)
+ try:
+ fh = file(outfile)
+ report = fh.read()
+ fh.close()
+ except IOError:
+ report = 'No dvipng error report available.'
if exit_status:
raise RuntimeError('dvipng was not able to \
process the flowing file:\n%s\nHere is the full report generated by dvipng: \
-\n\n'% dvifile + fh.read())
- else: mpl.verbose.report(fh.read(), 'debug')
- fh.close()
- os.remove(outfile)
+\n\n'% dvifile + report)
+ else: mpl.verbose.report(report, 'debug')
+ try: os.remove(outfile)
+ except OSError: pass
return pngfile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-07-17 12:01:59
|
Revision: 5771
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5771&view=rev
Author: dsdale
Date: 2008-07-17 12:01:50 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
improve error reporting in texmanager
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/texmanager.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-07-14 16:42:52 UTC (rev 5770)
+++ branches/v0_91_maint/CHANGELOG 2008-07-17 12:01:50 UTC (rev 5771)
@@ -1,3 +1,6 @@
+2008-07-16 Improve error handling in texmanager, thanks to Ian Henry
+ for reporting - DSD
+
2008-07-09 Improve mathtext radical rendering - MGD
2008-07-08 Improve mathtext superscript placement - MGD
Modified: branches/v0_91_maint/lib/matplotlib/texmanager.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/texmanager.py 2008-07-14 16:42:52 UTC (rev 5770)
+++ branches/v0_91_maint/lib/matplotlib/texmanager.py 2008-07-17 12:01:50 UTC (rev 5771)
@@ -255,16 +255,22 @@
%(os.path.split(texfile)[-1], outfile))
mpl.verbose.report(command, 'debug')
exit_status = os.system(command)
- fh = file(outfile)
+ try:
+ fh = file(outfile)
+ report = fh.read()
+ fh.close()
+ except IOError:
+ report = 'No latex error report available.'
if exit_status:
raise RuntimeError(('LaTeX was not able to process the following \
-string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + fh.read())
- else: mpl.verbose.report(fh.read(), 'debug')
- fh.close()
+string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + report)
+ else: mpl.verbose.report(report, 'debug')
for fname in glob.glob(basefile+'*'):
if fname.endswith('dvi'): pass
elif fname.endswith('tex'): pass
- else: os.remove(fname)
+ else:
+ try: os.remove(fname)
+ except OSError: pass
return dvifile
@@ -282,14 +288,19 @@
os.path.split(dvifile)[-1], outfile))
mpl.verbose.report(command, 'debug')
exit_status = os.system(command)
- fh = file(outfile)
+ try:
+ fh = file(outfile)
+ report = fh.read()
+ fh.close()
+ except IOError:
+ report = 'No dvipng error report available.'
if exit_status:
raise RuntimeError('dvipng was not able to \
process the flowing file:\n%s\nHere is the full report generated by dvipng: \
-\n\n'% dvifile + fh.read())
- else: mpl.verbose.report(fh.read(), 'debug')
- fh.close()
- os.remove(outfile)
+\n\n'% dvifile + report)
+ else: mpl.verbose.report(report, 'debug')
+ try: os.remove(outfile)
+ except OSError: pass
return pngfile
@@ -363,7 +374,7 @@
# white (1) this reduces to red = 1-alpha or alpha = 1-red
#alpha = npy.sqrt(1-X[:,:,0]) # should this be sqrt here?
alpha = 1-X[:,:,0]
-
+
else:
alpha = X[:,:,-1]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-07-14 16:42:59
|
Revision: 5770
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5770&view=rev
Author: jswhit
Date: 2008-07-14 09:42:52 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
add moll and robin examples
Modified Paths:
--------------
trunk/toolkits/basemap/examples/plot_tissot.py
Modified: trunk/toolkits/basemap/examples/plot_tissot.py
===================================================================
--- trunk/toolkits/basemap/examples/plot_tissot.py 2008-07-14 15:14:02 UTC (rev 5769)
+++ trunk/toolkits/basemap/examples/plot_tissot.py 2008-07-14 16:42:52 UTC (rev 5770)
@@ -19,13 +19,14 @@
m1 = Basemap(llcrnrlon=-180,llcrnrlat=-80,urcrnrlon=180,urcrnrlat=80,
projection='cyl')
m2 = Basemap(lon_0=-60,lat_0=45,projection='ortho')
-# use WGS84 ellipsoid in this one.
m3 = Basemap(llcrnrlon=-180,llcrnrlat=-70,urcrnrlon=180,urcrnrlat=70,
- projection='merc',lat_ts=20,rsphere=(6378137.0,6356752.3142))
+ projection='merc',lat_ts=20)
m4 = Basemap(lon_0=270,lat_0=90,boundinglat=10,projection='npstere')
m5 = Basemap(lon_0=270,lat_0=90,boundinglat=10,projection='nplaea')
+m6 = Basemap(lon_0=0,projection='moll')
+m7 = Basemap(lon_0=0,projection='robin')
-for m in [m1,m2,m3,m4,m5]:
+for m in [m1,m2,m3,m4,m5,m6,m7]:
# make a new figure.
fig = plt.figure()
# draw "circles" at specified longitudes and latitudes.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-14 15:14:13
|
Revision: 5769
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5769&view=rev
Author: jdh2358
Date: 2008-07-14 08:14:02 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
added support for pixels or data min coords to the rectangle selector widget
Modified Paths:
--------------
trunk/matplotlib/doc/faq/howto_faq.rst
trunk/matplotlib/examples/widgets/rectangle_selector.py
trunk/matplotlib/lib/matplotlib/artist.py
trunk/matplotlib/lib/matplotlib/pyplot.py
trunk/matplotlib/lib/matplotlib/widgets.py
Modified: trunk/matplotlib/doc/faq/howto_faq.rst
===================================================================
--- trunk/matplotlib/doc/faq/howto_faq.rst 2008-07-14 12:54:59 UTC (rev 5768)
+++ trunk/matplotlib/doc/faq/howto_faq.rst 2008-07-14 15:14:02 UTC (rev 5769)
@@ -6,6 +6,33 @@
.. contents::
+
+.. _howto-findobj:
+
+How do I find all the objects in my figure of a certain type?
+=============================================================
+
+Every matplotlib artist (see :ref:`artist-tutorial`) has a method
+called :meth:`~matplotlib.artist.Artist.findobj` that can be used to
+recursively search the artist for any artists it may contain that meet
+some criteria (eg match all :class:`~matplotlib.lines.Line2D`
+instances or match some arbitrary filter function). For example, the
+following snippet finds every object in the figure which has a
+`set_color` property and makes the object blue::
+
+ def myfunc(x):
+ return hasattr(x, 'set_color')
+
+ for o in fig.findobj(myfunc):
+ o.set_color('blue')
+
+You can also filter on class instances::
+
+ import matplotlib.text as text
+ for o in fig.findobj(text.Text):
+ o.set_fontstyle('italic')
+
+
.. _howto-transparent:
How do I save transparent figures?
Modified: trunk/matplotlib/examples/widgets/rectangle_selector.py
===================================================================
--- trunk/matplotlib/examples/widgets/rectangle_selector.py 2008-07-14 12:54:59 UTC (rev 5768)
+++ trunk/matplotlib/examples/widgets/rectangle_selector.py 2008-07-14 15:14:02 UTC (rev 5769)
@@ -29,5 +29,6 @@
# drawtype is 'box' or 'line' or 'none'
LS = RectangleSelector(current_ax, line_select_callback,
- drawtype='box',useblit=True)
+ drawtype='box',useblit=True,
+ minspanx=5,minspany=5,spancoords='pixels')
show()
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py 2008-07-14 12:54:59 UTC (rev 5768)
+++ trunk/matplotlib/lib/matplotlib/artist.py 2008-07-14 15:14:02 UTC (rev 5769)
@@ -510,6 +510,9 @@
def findobj(self, match=None):
"""
+ pyplot signature:
+ findobj(o=gcf(), match=None)
+
recursively find all :class:matplotlib.artist.Artist instances
contained in self
@@ -520,6 +523,8 @@
- function with signature ``boolean = match(artist)`` used to filter matches
- class instance: eg Line2D. Only return artists of class type
+
+ .. plot:: ../mpl_examples/pylab_examples/findobj_demo.py
"""
if match is None: # always return True
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-07-14 12:54:59 UTC (rev 5768)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-07-14 15:14:02 UTC (rev 5769)
@@ -7,7 +7,7 @@
from matplotlib.backend_bases import FigureCanvasBase
from matplotlib.image import imread as _imread
from matplotlib import rcParams, rcParamsDefault, get_backend
-from matplotlib.artist import getp, get
+from matplotlib.artist import getp, get, Artist
from matplotlib.artist import setp as _setp
from matplotlib.axes import Axes
from matplotlib.projections import PolarAxes
@@ -41,26 +41,11 @@
def findobj(o=None, match=None):
- """
- recursively find all :class:matplotlib.artist.Artist instances
- contained in artist instance *p*. if *o* is None, use
- current figure
-
- *match* can be
-
- - None: return all objects contained in artist (including artist)
-
- - function with signature ``boolean = match(artist)`` used to filter matches
-
- - class instance: eg Line2D. Only return artists of class type
-
- """
-
if o is None:
o = gcf()
return o.findobj(match)
+findobj.__doc__ = Artist.findobj.__doc__
-
def switch_backend(newbackend):
"""
Switch the default backend to newbackend. This feature is
Modified: trunk/matplotlib/lib/matplotlib/widgets.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/widgets.py 2008-07-14 12:54:59 UTC (rev 5768)
+++ trunk/matplotlib/lib/matplotlib/widgets.py 2008-07-14 15:14:02 UTC (rev 5769)
@@ -979,7 +979,7 @@
"""
Select a min/max range of the x axes for a matplotlib Axes
- Example usage:
+ Example usage::
from matplotlib.widgets import RectangleSelector
from pylab import *
@@ -1011,7 +1011,7 @@
"""
def __init__(self, ax, onselect, drawtype='box',
minspanx=None, minspany=None, useblit=False,
- lineprops=None, rectprops=None):
+ lineprops=None, rectprops=None, spancoords='data'):
"""
Create a selector in ax. When a selection is made, clear
@@ -1035,7 +1035,12 @@
Use type if you want the mouse to draw a line, a box or nothing
between click and actual position ny setting
+
drawtype = 'line', drawtype='box' or drawtype = 'none'.
+
+ spancoords is one of 'data' or 'pixels'. If 'data', minspanx
+ and minspanx will be interpreted in the same coordinates as
+ the x and ya axis, if 'pixels', they are in pixels
"""
self.ax = ax
self.visible = True
@@ -1072,6 +1077,10 @@
self.useblit = useblit
self.minspanx = minspanx
self.minspany = minspany
+
+ assert(spancoords in ('data', 'pixels'))
+
+ self.spancoords = spancoords
self.drawtype = drawtype
# will save the data (position at mouseclick)
self.eventpress = None
@@ -1125,15 +1134,22 @@
self.canvas.draw()
# release coordinates, button, ...
self.eventrelease = event
- xmin, ymin = self.eventpress.xdata, self.eventpress.ydata
- xmax, ymax = self.eventrelease.xdata, self.eventrelease.ydata
- # calculate dimensions of box or line get values in the right
- # order
+
+ if self.spancoords=='data':
+ xmin, ymin = self.eventpress.xdata, self.eventpress.ydata
+ xmax, ymax = self.eventrelease.xdata, self.eventrelease.ydata
+ # calculate dimensions of box or line get values in the right
+ # order
+ elif self.spancoords=='pixels':
+ xmin, ymin = self.eventpress.x, self.eventpress.y
+ xmax, ymax = self.eventrelease.x, self.eventrelease.y
+ else:
+ raise ValueError('spancoords must be "data" or "pixels"')
+
+
if xmin>xmax: xmin, xmax = xmax, xmin
if ymin>ymax: ymin, ymax = ymax, ymin
-
-
spanx = xmax - xmin
spany = ymax - ymin
xproblems = self.minspanx is not None and spanx<self.minspanx
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-14 12:55:03
|
Revision: 5768
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5768&view=rev
Author: mdboom
Date: 2008-07-14 05:54:59 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
Remove on-line of cruft (thanks, Ryan May)
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-07-14 12:10:34 UTC (rev 5767)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-07-14 12:54:59 UTC (rev 5768)
@@ -93,7 +93,6 @@
if len(offsets.shape) == 1:
offsets = offsets[np.newaxis,:] # Make it Nx2.
if transOffset is not None:
- Affine2D = transforms.Affine2D
self._offsets = offsets
self._transOffset = transOffset
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-07-14 12:10:36
|
Revision: 5767
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5767&view=rev
Author: jswhit
Date: 2008-07-14 05:10:34 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
add final examples.
Modified Paths:
--------------
trunk/toolkits/basemap/doc/users/mapsetup.rst
Added Paths:
-----------
trunk/toolkits/basemap/doc/users/aeqd.rst
trunk/toolkits/basemap/doc/users/paeqd.rst
trunk/toolkits/basemap/doc/users/plaea.rst
trunk/toolkits/basemap/doc/users/pstere.rst
Removed Paths:
-------------
trunk/toolkits/basemap/doc/users/azeqd.rst
Added: trunk/toolkits/basemap/doc/users/aeqd.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/aeqd.rst (rev 0)
+++ trunk/toolkits/basemap/doc/users/aeqd.rst 2008-07-14 12:10:34 UTC (rev 5767)
@@ -0,0 +1,15 @@
+.. _aeqd:
+
+Azimuthal Equidistant Projection
+================================
+
+The shortest route from the center of the map
+to any other point is a straight line in the azimuthal
+equidistant projection.
+So, for the specified point, all points that lie on a circle around
+this point are equidistant on the surface of the earth on this projection.
+The specified point ``lon_0, lat_0`` shows up as a black dot in the center of the map.
+
+.. literalinclude:: figures/aeqd.py
+
+.. image:: figures/aeqd.png
Deleted: trunk/toolkits/basemap/doc/users/azeqd.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/azeqd.rst 2008-07-14 11:55:41 UTC (rev 5766)
+++ trunk/toolkits/basemap/doc/users/azeqd.rst 2008-07-14 12:10:34 UTC (rev 5767)
@@ -1,15 +0,0 @@
-.. _azeqd:
-
-Azimuthal Equidistant Projection
-================================
-
-The shortest route from the center of the map
-to any other point is a straight line in the azimuthal
-equidistant projection.
-So, for the specified point, all points that lie on a circle around
-this point are equidistant on the surface of the earth on this projection.
-The specified point ``lon_0, lat_0`` shows up as a black dot in the center of the map.
-
-.. literalinclude:: figures/azeqd.py
-
-.. image:: figures/azeqd.png
Modified: trunk/toolkits/basemap/doc/users/mapsetup.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/mapsetup.rst 2008-07-14 11:55:41 UTC (rev 5766)
+++ trunk/toolkits/basemap/doc/users/mapsetup.rst 2008-07-14 12:10:34 UTC (rev 5767)
@@ -32,7 +32,7 @@
.. toctree::
- azeqd.rst
+ aeqd.rst
gnomon.rst
ortho.rst
geos.rst
@@ -51,3 +51,6 @@
stere.rst
eqdc.rst
aea.rst
+ pstere.rst
+ plaea.rst
+ paeqd.rst
Added: trunk/toolkits/basemap/doc/users/paeqd.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/paeqd.rst (rev 0)
+++ trunk/toolkits/basemap/doc/users/paeqd.rst 2008-07-14 12:10:34 UTC (rev 5767)
@@ -0,0 +1,15 @@
+.. _paeqd:
+
+Polar Azimuthal Equidistant Projection
+======================================
+
+For convenience, the projections ``npaeqd`` and ``spaeqd`` are provided
+for easy access to the polar aspect of the azimuthal equidistant projection.
+
+.. literalinclude:: figures/npaeqd.py
+
+.. image:: figures/npaeqd.png
+
+.. literalinclude:: figures/spaeqd.py
+
+.. image:: figures/spaeqd.png
Added: trunk/toolkits/basemap/doc/users/plaea.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/plaea.rst (rev 0)
+++ trunk/toolkits/basemap/doc/users/plaea.rst 2008-07-14 12:10:34 UTC (rev 5767)
@@ -0,0 +1,16 @@
+.. _plaea:
+
+Polar Lambert Azimuthal Projection
+==================================
+
+For convenience, the projections ``nplaea`` and ``splaea`` are provided
+for easy access to the polar aspect of the lambert azimuthal equal-area
+projection.
+
+.. literalinclude:: figures/nplaea.py
+
+.. image:: figures/nplaea.png
+
+.. literalinclude:: figures/splaea.py
+
+.. image:: figures/splaea.png
Added: trunk/toolkits/basemap/doc/users/pstere.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/pstere.rst (rev 0)
+++ trunk/toolkits/basemap/doc/users/pstere.rst 2008-07-14 12:10:34 UTC (rev 5767)
@@ -0,0 +1,15 @@
+.. _pstere:
+
+Polar Stereographic Projection
+==============================
+
+For convenience, the projections ``npstere`` and ``spstere`` are provided
+for easy access to the polar aspect of the stereographic conformal projection.
+
+.. literalinclude:: figures/npstere.py
+
+.. image:: figures/npstere.png
+
+.. literalinclude:: figures/spstere.py
+
+.. image:: figures/spstere.png
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-07-14 11:55:46
|
Revision: 5766
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5766&view=rev
Author: jswhit
Date: 2008-07-14 04:55:41 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
final examples added.
Modified Paths:
--------------
trunk/toolkits/basemap/doc/users/figures/stere.py
Added Paths:
-----------
trunk/toolkits/basemap/doc/users/figures/aeqd.py
trunk/toolkits/basemap/doc/users/figures/npaeqd.py
trunk/toolkits/basemap/doc/users/figures/nplaea.py
trunk/toolkits/basemap/doc/users/figures/npstere.py
trunk/toolkits/basemap/doc/users/figures/spaeqd.py
trunk/toolkits/basemap/doc/users/figures/splaea.py
trunk/toolkits/basemap/doc/users/figures/spstere.py
Added: trunk/toolkits/basemap/doc/users/figures/aeqd.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/aeqd.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/aeqd.py 2008-07-14 11:55:41 UTC (rev 5766)
@@ -0,0 +1,20 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+width = 28000000; lon_0 = -105; lat_0 = 40
+m = Basemap(width=width,height=width,projection='aeqd',
+ lat_0=lat_0,lon_0=lon_0)
+# fill background.
+m.drawmapboundary(fill_color='aqua')
+# draw coasts and fill continents.
+m.drawcoastlines(linewidth=0.5)
+m.fillcontinents(color='coral',lake_color='aqua')
+# 20 degree graticule.
+m.drawparallels(np.arange(-80,81,20))
+m.drawmeridians(np.arange(-180,180,20))
+# draw a black dot at the center.
+xpt, ypt = m(lon_0, lat_0)
+m.plot([xpt],[ypt],'ko')
+# draw the title.
+plt.title('Azimuthal Equidistant Projection')
+plt.savefig('aeqd.png')
Added: trunk/toolkits/basemap/doc/users/figures/npaeqd.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/npaeqd.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/npaeqd.py 2008-07-14 11:55:41 UTC (rev 5766)
@@ -0,0 +1,24 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib.patches import Polygon
+# setup north polar aimuthal equidistant basemap.
+# The longitude lon_0 is at 6-o'clock, and the
+# latitude circle boundinglat is tangent to the edge
+# of the map at lon_0.
+m = Basemap(projection='npaeqd',boundinglat=10,lon_0=270,resolution='l')
+m.drawcoastlines()
+m.fillcontinents(color='coral',lake_color='aqua')
+# draw parallels and meridians.
+m.drawparallels(np.arange(-80.,81.,20.))
+m.drawmeridians(np.arange(-180.,181.,20.))
+m.drawmapboundary(fill_color='aqua')
+# draw tissot's indicatrix to show distortion.
+ax = plt.gca()
+for y in np.linspace(m.ymax/20,19*m.ymax/20,10):
+ for x in np.linspace(m.xmax/20,19*m.xmax/20,10):
+ lon, lat = m(x,y,inverse=True)
+ poly = m.tissot(lon,lat,2.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
+plt.title("North Polar Azimuthal Equidistant Projection")
+plt.savefig('npaeqd.png')
Added: trunk/toolkits/basemap/doc/users/figures/nplaea.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/nplaea.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/nplaea.py 2008-07-14 11:55:41 UTC (rev 5766)
@@ -0,0 +1,24 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib.patches import Polygon
+# setup north polar lambert azimuthal basemap.
+# The longitude lon_0 is at 6-o'clock, and the
+# latitude circle boundinglat is tangent to the edge
+# of the map at lon_0.
+m = Basemap(projection='nplaea',boundinglat=10,lon_0=270,resolution='l')
+m.drawcoastlines()
+m.fillcontinents(color='coral',lake_color='aqua')
+# draw parallels and meridians.
+m.drawparallels(np.arange(-80.,81.,20.))
+m.drawmeridians(np.arange(-180.,181.,20.))
+m.drawmapboundary(fill_color='aqua')
+# draw tissot's indicatrix to show distortion.
+ax = plt.gca()
+for y in np.linspace(m.ymax/20,19*m.ymax/20,10):
+ for x in np.linspace(m.xmax/20,19*m.xmax/20,10):
+ lon, lat = m(x,y,inverse=True)
+ poly = m.tissot(lon,lat,2.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
+plt.title("North Polar Lambert Azimuthal Projection")
+plt.savefig('nplaea.png')
Added: trunk/toolkits/basemap/doc/users/figures/npstere.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/npstere.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/npstere.py 2008-07-14 11:55:41 UTC (rev 5766)
@@ -0,0 +1,24 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+# setup north polar stereographic basemap.
+# The longitude lon_0 is at 6-o'clock, and the
+# latitude circle boundinglat is tangent to the edge
+# of the map at lon_0. Default value of lat_ts
+# (latitude of true scale) is pole.
+m = Basemap(projection='npstere',boundinglat=10,lon_0=270,resolution='l')
+m.drawcoastlines()
+m.fillcontinents(color='coral',lake_color='aqua')
+# draw parallels and meridians.
+m.drawparallels(np.arange(-80.,81.,20.))
+m.drawmeridians(np.arange(-180.,181.,20.))
+m.drawmapboundary(fill_color='aqua')
+# draw tissot's indicatrix to show distortion.
+ax = plt.gca()
+for y in np.linspace(m.ymax/20,19*m.ymax/20,10):
+ for x in np.linspace(m.xmax/20,19*m.xmax/20,10):
+ lon, lat = m(x,y,inverse=True)
+ poly = m.tissot(lon,lat,2.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
+plt.title("North Polar Stereographic Projection")
+plt.savefig('npstere.png')
Added: trunk/toolkits/basemap/doc/users/figures/spaeqd.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/spaeqd.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/spaeqd.py 2008-07-14 11:55:41 UTC (rev 5766)
@@ -0,0 +1,23 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+# setup south polar aimuthal equidistant basemap.
+# The longitude lon_0 is at 6-o'clock, and the
+# latitude circle boundinglat is tangent to the edge
+# of the map at lon_0.
+m = Basemap(projection='spaeqd',boundinglat=-10,lon_0=90,resolution='l')
+m.drawcoastlines()
+m.fillcontinents(color='coral',lake_color='aqua')
+# draw parallels and meridians.
+m.drawparallels(np.arange(-80.,81.,20.))
+m.drawmeridians(np.arange(-180.,181.,20.))
+m.drawmapboundary(fill_color='aqua')
+# draw tissot's indicatrix to show distortion.
+ax = plt.gca()
+for y in np.linspace(19*m.ymin/20,m.ymin/20,10):
+ for x in np.linspace(19*m.xmin/20,m.xmin/20,10):
+ lon, lat = m(x,y,inverse=True)
+ poly = m.tissot(lon,lat,2.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
+plt.title("South Polar Azimuthal Equidistant Projection")
+plt.savefig('spaeqd.png')
Added: trunk/toolkits/basemap/doc/users/figures/splaea.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/splaea.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/splaea.py 2008-07-14 11:55:41 UTC (rev 5766)
@@ -0,0 +1,23 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+# setup south polar lambert azimuthal basemap.
+# The longitude lon_0 is at 6-o'clock, and the
+# latitude circle boundinglat is tangent to the edge
+# of the map at lon_0.
+m = Basemap(projection='splaea',boundinglat=-10,lon_0=90,resolution='l')
+m.drawcoastlines()
+m.fillcontinents(color='coral',lake_color='aqua')
+# draw parallels and meridians.
+m.drawparallels(np.arange(-80.,81.,20.))
+m.drawmeridians(np.arange(-180.,181.,20.))
+m.drawmapboundary(fill_color='aqua')
+# draw tissot's indicatrix to show distortion.
+ax = plt.gca()
+for y in np.linspace(19*m.ymin/20,m.ymin/20,10):
+ for x in np.linspace(19*m.xmin/20,m.xmin/20,10):
+ lon, lat = m(x,y,inverse=True)
+ poly = m.tissot(lon,lat,2.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
+plt.title("South Polar Lambert Azimuthal Projection")
+plt.savefig('splaea.png')
Added: trunk/toolkits/basemap/doc/users/figures/spstere.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/spstere.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/spstere.py 2008-07-14 11:55:41 UTC (rev 5766)
@@ -0,0 +1,24 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+# setup north polar stereographic basemap.
+# The longitude lon_0 is at 6-o'clock, and the
+# latitude circle boundinglat is tangent to the edge
+# of the map at lon_0. Default value of lat_ts
+# (latitude of true scale) is pole.
+m = Basemap(projection='spstere',boundinglat=-10,lon_0=90,resolution='l')
+m.drawcoastlines()
+m.fillcontinents(color='coral',lake_color='aqua')
+# draw parallels and meridians.
+m.drawparallels(np.arange(-80.,81.,20.))
+m.drawmeridians(np.arange(-180.,181.,20.))
+m.drawmapboundary(fill_color='aqua')
+# draw tissot's indicatrix to show distortion.
+ax = plt.gca()
+for y in np.linspace(19*m.ymin/20,m.ymin/20,10):
+ for x in np.linspace(19*m.xmin/20,m.xmin/20,10):
+ lon, lat = m(x,y,inverse=True)
+ poly = m.tissot(lon,lat,2.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
+plt.title("South Polar Stereographic Projection")
+plt.savefig('spstere.png')
Modified: trunk/toolkits/basemap/doc/users/figures/stere.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/stere.py 2008-07-14 01:58:13 UTC (rev 5765)
+++ trunk/toolkits/basemap/doc/users/figures/stere.py 2008-07-14 11:55:41 UTC (rev 5766)
@@ -1,7 +1,6 @@
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
-from matplotlib.patches import Polygon
# setup stereographic basemap.
# lat_ts is latitude of true scale.
# lon_0,lat_0 is central point.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-07-14 01:58:14
|
Revision: 5765
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5765&view=rev
Author: jswhit
Date: 2008-07-13 18:58:13 -0700 (Sun, 13 Jul 2008)
Log Message:
-----------
fixes for updated tissot method.
Modified Paths:
--------------
trunk/toolkits/basemap/doc/users/figures/aea.py
trunk/toolkits/basemap/doc/users/figures/eqdc.py
trunk/toolkits/basemap/doc/users/figures/laea.py
trunk/toolkits/basemap/doc/users/figures/lcc.py
trunk/toolkits/basemap/doc/users/figures/stere.py
Modified: trunk/toolkits/basemap/doc/users/figures/aea.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/aea.py 2008-07-13 20:51:25 UTC (rev 5764)
+++ trunk/toolkits/basemap/doc/users/figures/aea.py 2008-07-14 01:58:13 UTC (rev 5765)
@@ -1,7 +1,6 @@
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
-from matplotlib.patches import Polygon
# setup albers equal area conic basemap
# lat_1 is first standard parallel.
# lat_2 is second standard parallel.
@@ -21,8 +20,7 @@
for y in np.linspace(m.ymax/20,19*m.ymax/20,10):
for x in np.linspace(m.xmax/20,19*m.xmax/20,12):
lon, lat = m(x,y,inverse=True)
- seg = m.tissot(lon,lat,1.,100)
- poly = Polygon(seg,facecolor='green',zorder=10,alpha=0.5)
- ax.add_patch(poly)
+ poly = m.tissot(lon,lat,1.25,100,\
+ facecolor='green',zorder=10,alpha=0.5)
plt.title("Albers Equal Area Projection")
plt.savefig('aea.png')
Modified: trunk/toolkits/basemap/doc/users/figures/eqdc.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/eqdc.py 2008-07-13 20:51:25 UTC (rev 5764)
+++ trunk/toolkits/basemap/doc/users/figures/eqdc.py 2008-07-14 01:58:13 UTC (rev 5765)
@@ -1,7 +1,6 @@
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
-from matplotlib.patches import Polygon
# setup equidistant conic basemap.
# lat_1 is first standard parallel.
# lat_2 is second standard parallel.
@@ -20,8 +19,7 @@
for y in np.linspace(m.ymax/20,19*m.ymax/20,9):
for x in np.linspace(m.xmax/20,19*m.xmax/20,12):
lon, lat = m(x,y,inverse=True)
- seg = m.tissot(lon,lat,1.5,100)
- poly = Polygon(seg,facecolor='green',zorder=10,alpha=0.5)
- ax.add_patch(poly)
+ poly = m.tissot(lon,lat,1.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
plt.title("Equidistant Conic Projection")
plt.savefig('eqdc.png')
Modified: trunk/toolkits/basemap/doc/users/figures/laea.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/laea.py 2008-07-13 20:51:25 UTC (rev 5764)
+++ trunk/toolkits/basemap/doc/users/figures/laea.py 2008-07-14 01:58:13 UTC (rev 5765)
@@ -1,7 +1,6 @@
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
-from matplotlib.patches import Polygon
# setup lambert azimuthal equal area basemap.
# lat_ts is latitude of true scale.
# lon_0,lat_0 is central point.
@@ -19,8 +18,7 @@
for y in np.linspace(m.ymax/20,19*m.ymax/20,9):
for x in np.linspace(m.xmax/20,19*m.xmax/20,12):
lon, lat = m(x,y,inverse=True)
- seg = m.tissot(lon,lat,1.5,100)
- poly = Polygon(seg,facecolor='green',zorder=10,alpha=0.5)
- ax.add_patch(poly)
+ poly = m.tissot(lon,lat,1.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
plt.title("Lambert Azimuthal Equal Area Projection")
plt.savefig('laea.png')
Modified: trunk/toolkits/basemap/doc/users/figures/lcc.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/lcc.py 2008-07-13 20:51:25 UTC (rev 5764)
+++ trunk/toolkits/basemap/doc/users/figures/lcc.py 2008-07-14 01:58:13 UTC (rev 5765)
@@ -1,7 +1,6 @@
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
-from matplotlib.patches import Polygon
# setup lambert conformal basemap.
# lat_1 is first standard parallel.
# lat_2 is second standard parallel (defaults to lat_1).
@@ -24,8 +23,7 @@
for y in np.linspace(m.ymax/20,19*m.ymax/20,9):
for x in np.linspace(m.xmax/20,19*m.xmax/20,12):
lon, lat = m(x,y,inverse=True)
- seg = m.tissot(lon,lat,1.5,100)
- poly = Polygon(seg,facecolor='green',zorder=10,alpha=0.5)
- ax.add_patch(poly)
+ poly = m.tissot(lon,lat,1.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
plt.title("Lambert Conformal Projection")
plt.savefig('lcc.png')
Modified: trunk/toolkits/basemap/doc/users/figures/stere.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/stere.py 2008-07-13 20:51:25 UTC (rev 5764)
+++ trunk/toolkits/basemap/doc/users/figures/stere.py 2008-07-14 01:58:13 UTC (rev 5765)
@@ -19,8 +19,7 @@
for y in np.linspace(m.ymax/20,19*m.ymax/20,9):
for x in np.linspace(m.xmax/20,19*m.xmax/20,12):
lon, lat = m(x,y,inverse=True)
- seg = m.tissot(lon,lat,1.5,100)
- poly = Polygon(seg,facecolor='green',zorder=10,alpha=0.5)
- ax.add_patch(poly)
+ poly = m.tissot(lon,lat,1.5,100,\
+ facecolor='green',zorder=10,alpha=0.5)
plt.title("Stereographic Projection")
plt.savefig('stere.png')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-07-13 20:51:28
|
Revision: 5764
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5764&view=rev
Author: efiring
Date: 2008-07-13 13:51:25 -0700 (Sun, 13 Jul 2008)
Log Message:
-----------
Fix PatchCollection bug found by Ryan May
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-07-13 20:29:55 UTC (rev 5763)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-07-13 20:51:25 UTC (rev 5764)
@@ -888,7 +888,7 @@
if match_original:
def determine_facecolor(patch):
- if patch.fill():
+ if patch.fill:
return patch.get_facecolor()
return [0, 0, 0, 0]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-07-13 20:29:58
|
Revision: 5763
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5763&view=rev
Author: jswhit
Date: 2008-07-13 13:29:55 -0700 (Sun, 13 Jul 2008)
Log Message:
-----------
have tissot method do actual drawing.
Modified Paths:
--------------
trunk/toolkits/basemap/examples/plot_tissot.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/examples/plot_tissot.py
===================================================================
--- trunk/toolkits/basemap/examples/plot_tissot.py 2008-07-13 13:27:33 UTC (rev 5762)
+++ trunk/toolkits/basemap/examples/plot_tissot.py 2008-07-13 20:29:55 UTC (rev 5763)
@@ -2,7 +2,6 @@
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from mpl_toolkits.basemap import __version__ as basemap_version
-from matplotlib.patches import Polygon
# Tissot's Indicatrix (http://en.wikipedia.org/wiki/Tissot's_Indicatrix).
# These diagrams illustrate the distortion inherent in all map projections.
@@ -29,13 +28,10 @@
for m in [m1,m2,m3,m4,m5]:
# make a new figure.
fig = plt.figure()
- ax = plt.gca()
# draw "circles" at specified longitudes and latitudes.
for parallel in range(-60,61,30):
for meridian in range(-165,166,30):
- seg = m.tissot(meridian,parallel,6,100)
- poly = Polygon(seg,facecolor='green',zorder=10,alpha=0.5)
- ax.add_patch(poly)
+ poly = m.tissot(meridian,parallel,6,100,facecolor='green',zorder=10,alpha=0.5)
# draw meridians and parallels.
m.drawparallels(np.arange(-60,61,30))
m.drawmeridians(np.arange(-180,180,60))
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-07-13 13:27:33 UTC (rev 5762)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-07-13 20:29:55 UTC (rev 5763)
@@ -2146,16 +2146,30 @@
if v == ([], []): del linecolls[k]
return linecolls
- def tissot(self,lon_0,lat_0,radius_deg,npts):
+ def tissot(self,lon_0,lat_0,radius_deg,npts,ax=None,**kwargs):
"""
- create list of ``npts`` x,y pairs that are equidistant on the
- surface of the earth from central point ``lon_0,lat_0`` and form
- an ellipse with radius of ``radius_deg`` degrees of latitude along
- longitude ``lon_0``.
- The ellipse represents a Tissot's indicatrix
+ Draw a polygon centered at ``lon_0,lat_0``. The polygon
+ approximates a circle on the surface of the earth with radius
+ ``radius_deg`` degrees latitude along longitude ``lon_0``,
+ made up of ``npts`` vertices.
+ The polygon represents a Tissot's indicatrix
(http://en.wikipedia.org/wiki/Tissot's_Indicatrix),
which when drawn on a map shows the distortion
- inherent in the map projection."""
+ inherent in the map projection.
+
+ Extra keyword ``ax`` can be used to override the default axis instance.
+
+ Other \**kwargs passed on to matplotlib.patches.Polygon."""
+ if not kwargs.has_key('ax') and self.ax is None:
+ try:
+ ax = plt.gca()
+ except:
+ import matplotlib.pyplot as plt
+ ax = plt.gca()
+ elif not kwargs.has_key('ax') and self.ax is not None:
+ ax = self.ax
+ else:
+ ax = kwargs.pop('ax')
g = pyproj.Geod(a=self.rmajor,b=self.rminor)
az12,az21,dist = g.inv(lon_0,lat_0,lon_0,lat_0+radius_deg)
seg = [self(lon_0,lat_0+radius_deg)]
@@ -2172,7 +2186,11 @@
# add segment if it is in the map projection region.
if x < 1.e20 and y < 1.e20:
seg.append((x,y))
- return seg
+ poly = Polygon(seg,**kwargs)
+ ax.add_patch(poly)
+ # set axes limits to fit map region.
+ self.set_axes_limits(ax=ax)
+ return poly
def gcpoints(self,lon1,lat1,lon2,lat2,npoints):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-07-13 13:27:37
|
Revision: 5762
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5762&view=rev
Author: jswhit
Date: 2008-07-13 06:27:33 -0700 (Sun, 13 Jul 2008)
Log Message:
-----------
update
Modified Paths:
--------------
trunk/toolkits/basemap/doc/users/figures/aea.py
Modified: trunk/toolkits/basemap/doc/users/figures/aea.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/aea.py 2008-07-13 13:24:30 UTC (rev 5761)
+++ trunk/toolkits/basemap/doc/users/figures/aea.py 2008-07-13 13:27:33 UTC (rev 5762)
@@ -6,7 +6,7 @@
# lat_1 is first standard parallel.
# lat_2 is second standard parallel.
# lon_0,lat_0 is central point.
-m = Basemap(width=8000000,height=6000000,
+m = Basemap(width=8000000,height=7000000,
resolution='l',projection='aea',\
lat_1=40.,lat_2=60,lon_0=35,lat_0=50)
m.drawcoastlines()
@@ -18,7 +18,7 @@
m.drawmapboundary(fill_color='aqua')
# draw tissot's indicatrix to show distortion.
ax = plt.gca()
-for y in np.linspace(m.ymax/20,19*m.ymax/20,9):
+for y in np.linspace(m.ymax/20,19*m.ymax/20,10):
for x in np.linspace(m.xmax/20,19*m.xmax/20,12):
lon, lat = m(x,y,inverse=True)
seg = m.tissot(lon,lat,1.,100)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|