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.
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins