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: <lee...@us...> - 2009-12-16 01:22:52
|
Revision: 8035
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8035&view=rev
Author: leejjoon
Date: 2009-12-16 01:22:41 +0000 (Wed, 16 Dec 2009)
Log Message:
-----------
support unsampled image for ps backend
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
trunk/matplotlib/lib/matplotlib/image.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-12-15 02:57:46 UTC (rev 8034)
+++ trunk/matplotlib/CHANGELOG 2009-12-16 01:22:41 UTC (rev 8035)
@@ -1,3 +1,5 @@
+2009-12-15 Add raw-image (unsampled) support for the ps backend. - JJL
+
2009-12-14 Add patch_artist kwarg to boxplot, but keep old default.
Convert boxplot_demo2.py to use the new patch_artist. - ADS
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-12-15 02:57:46 UTC (rev 8034)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-12-16 01:22:41 UTC (rev 8035)
@@ -340,6 +340,13 @@
"""
return False
+ def option_scale_image(self):
+ """
+ override this method for renderers that support arbitrary
+ scaling of image (most of the vector backend).
+ """
+ return False
+
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!'):
"""
"""
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py 2009-12-15 02:57:46 UTC (rev 8034)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py 2009-12-16 01:22:41 UTC (rev 8035)
@@ -59,7 +59,7 @@
get_texmanager get_text_width_height_descent new_gc open_group
option_image_nocomposite points_to_pixels strip_math
start_filter stop_filter draw_gouraud_triangle
- draw_gouraud_triangles
+ draw_gouraud_triangles option_scale_image
""".split()
def _set_current_renderer(self, renderer):
self._renderer = renderer
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2009-12-15 02:57:46 UTC (rev 8034)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2009-12-16 01:22:41 UTC (rev 8035)
@@ -380,8 +380,14 @@
"""
return self.image_magnification
- def draw_image(self, gc, x, y, im):
+ def option_scale_image(self):
"""
+ ps backend support arbitrary scaling of image.
+ """
+ return True
+
+ def draw_image(self, gc, x, y, im, sx=None, sy=None):
+ """
Draw the Image instance into the current axes; x is the
distance in pixels from the left hand side of the canvas and y
is the distance from bottom
@@ -400,9 +406,13 @@
imagecmd = "false 3 colorimage"
hexlines = '\n'.join(self._hex_lines(bits))
- xscale, yscale = (
- w/self.image_magnification, h/self.image_magnification)
-
+ if sx is None:
+ sx = 1./self.image_magnification
+ if sy is None:
+ sy = 1./self.image_magnification
+
+ xscale, yscale = (w*sx, h*sy)
+
figh = self.height*72
#print 'values', origin, flipud, figh, h, y
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2009-12-15 02:57:46 UTC (rev 8034)
+++ trunk/matplotlib/lib/matplotlib/image.py 2009-12-16 01:22:41 UTC (rev 8035)
@@ -127,21 +127,140 @@
def make_image(self, magnification=1.0):
raise RuntimeError('The make_image method must be overridden.')
+
+ def _get_unsampled_image(self, A, image_extents, viewlim):
+ """
+ convert numpy array A with given extents ([x1, x2, y1, y2] in
+ data coordinate) into the Image, given the vielim (should be a
+ bbox instance). Image will be clipped if the extents is
+ significantly larger than the viewlim.
+ """
+ xmin, xmax, ymin, ymax = image_extents
+ dxintv = xmax-xmin
+ dyintv = ymax-ymin
+
+ # the viewport scale factor
+ sx = dxintv/viewlim.width
+ sy = dyintv/viewlim.height
+ numrows, numcols = A.shape[:2]
+ if sx > 2:
+ x0 = (viewim.x0-xmin)/dxintv * numcols
+ ix0 = max(0, int(x0 - self._filterrad))
+ x1 = (viewlim.x1-xmin)/dxintv * numcols
+ ix1 = min(numcols, int(x1 + self._filterrad))
+ xslice = slice(ix0, ix1)
+ xmin_old = xmin
+ xmin = xmin_old + ix0*dxintv/numcols
+ xmax = xmin_old + ix1*dxintv/numcols
+ dxintv = xmax - xmin
+ sx = dxintv/viewlim.width
+ else:
+ xslice = slice(0, numcols)
+
+ if sy > 2:
+ y0 = (viewlim.y0-ymin)/dyintv * numrows
+ iy0 = max(0, int(y0 - self._filterrad))
+ y1 = (viewlim.y1-ymin)/dyintv * numrows
+ iy1 = min(numrows, int(y1 + self._filterrad))
+ if self.origin == 'upper':
+ yslice = slice(numrows-iy1, numrows-iy0)
+ else:
+ yslice = slice(iy0, iy1)
+ ymin_old = ymin
+ ymin = ymin_old + iy0*dyintv/numrows
+ ymax = ymin_old + iy1*dyintv/numrows
+ dyintv = ymax - ymin
+ sy = dyintv/self.axes.viewLim.height
+ else:
+ yslice = slice(0, numrows)
+
+ if xslice != self._oldxslice or yslice != self._oldyslice:
+ self._imcache = None
+ self._oldxslice = xslice
+ self._oldyslice = yslice
+
+ if self._imcache is None:
+ if self._A.dtype == np.uint8 and len(self._A.shape) == 3:
+ im = _image.frombyte(self._A[yslice,xslice,:], 0)
+ im.is_grayscale = False
+ else:
+ if self._rgbacache is None:
+ x = self.to_rgba(self._A, self._alpha)
+ self._rgbacache = x
+ else:
+ x = self._rgbacache
+ im = _image.fromarray(x[yslice,xslice], 0)
+ if len(self._A.shape) == 2:
+ im.is_grayscale = self.cmap.is_gray()
+ else:
+ im.is_grayscale = False
+ self._imcache = im
+
+ if self.origin=='upper':
+ im.flipud_in()
+ else:
+ im = self._imcache
+
+ return im, xmin, ymin, dxintv, dyintv, sx, sy
+
+
+ def _draw_unsampled_image(self, renderer, gc):
+ """
+ draw unsampled image. The renderer should support a draw_image method
+ with scale parameter.
+ """
+ im, xmin, ymin, dxintv, dyintv, sx, sy = \
+ self._get_unsampled_image(self._A, self.get_extent(), self.axes.viewLim)
+
+ if im is None: return # I'm not if this check is required. -JJL
+
+ transData = self.axes.transData
+ xx1, yy1 = transData.transform_point((xmin, ymin))
+ xx2, yy2 = transData.transform_point((xmin+dxintv, ymin+dyintv))
+
+ fc = self.axes.patch.get_facecolor()
+ bg = mcolors.colorConverter.to_rgba(fc, 0)
+ im.set_bg( *bg)
+
+ # image input dimensions
+ im.reset_matrix()
+ numrows, numcols = im.get_size()
+
+ im.resize(numcols, numrows) # just to create im.bufOut that is required by backends. There may be better solution -JJL
+
+ sx = (xx2-xx1)/numcols
+ sy = (yy2-yy1)/numrows
+ im._url = self.get_url()
+ renderer.draw_image(gc, xx1, yy1, im, sx, sy)
+
+
+ def _check_unsampled_image(self, renderer):
+ """
+ return True if the image is better to be drawn unsampled.
+ The derived class needs to override it.
+ """
+ return False
+
@allow_rasterization
def draw(self, renderer, *args, **kwargs):
if not self.get_visible(): return
if (self.axes.get_xscale() != 'linear' or
self.axes.get_yscale() != 'linear'):
warnings.warn("Images are not supported on non-linear axes.")
- im = self.make_image(renderer.get_image_magnification())
- if im is None:
- return
- im._url = self.get_url()
+
l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds
gc = renderer.new_gc()
gc.set_clip_rectangle(self.axes.bbox.frozen())
gc.set_clip_path(self.get_clip_path())
- renderer.draw_image(gc, l, b, im)
+
+ if self._check_unsampled_image(renderer):
+ self._draw_unsampled_image(renderer, gc)
+ else:
+ im = self.make_image(renderer.get_image_magnification())
+ if im is None:
+ return
+ im._url = self.get_url()
+ renderer.draw_image(gc, l, b, im)
gc.restore()
def contains(self, mouseevent):
@@ -338,72 +457,9 @@
if self._A is None:
raise RuntimeError('You must first set the image array or the image attribute')
- xmin, xmax, ymin, ymax = self.get_extent()
- dxintv = xmax-xmin
- dyintv = ymax-ymin
+ im, xmin, ymin, dxintv, dyintv, sx, sy = \
+ self._get_unsampled_image(self._A, self.get_extent(), self.axes.viewLim)
- # the viewport scale factor
- sx = dxintv/self.axes.viewLim.width
- sy = dyintv/self.axes.viewLim.height
- numrows, numcols = self._A.shape[:2]
- if sx > 2:
- x0 = (self.axes.viewLim.x0-xmin)/dxintv * numcols
- ix0 = max(0, int(x0 - self._filterrad))
- x1 = (self.axes.viewLim.x1-xmin)/dxintv * numcols
- ix1 = min(numcols, int(x1 + self._filterrad))
- xslice = slice(ix0, ix1)
- xmin_old = xmin
- xmin = xmin_old + ix0*dxintv/numcols
- xmax = xmin_old + ix1*dxintv/numcols
- dxintv = xmax - xmin
- sx = dxintv/self.axes.viewLim.width
- else:
- xslice = slice(0, numcols)
-
- if sy > 2:
- y0 = (self.axes.viewLim.y0-ymin)/dyintv * numrows
- iy0 = max(0, int(y0 - self._filterrad))
- y1 = (self.axes.viewLim.y1-ymin)/dyintv * numrows
- iy1 = min(numrows, int(y1 + self._filterrad))
- if self.origin == 'upper':
- yslice = slice(numrows-iy1, numrows-iy0)
- else:
- yslice = slice(iy0, iy1)
- ymin_old = ymin
- ymin = ymin_old + iy0*dyintv/numrows
- ymax = ymin_old + iy1*dyintv/numrows
- dyintv = ymax - ymin
- sy = dyintv/self.axes.viewLim.height
- else:
- yslice = slice(0, numrows)
-
- if xslice != self._oldxslice or yslice != self._oldyslice:
- self._imcache = None
- self._oldxslice = xslice
- self._oldyslice = yslice
-
- if self._imcache is None:
- if self._A.dtype == np.uint8 and len(self._A.shape) == 3:
- im = _image.frombyte(self._A[yslice,xslice,:], 0)
- im.is_grayscale = False
- else:
- if self._rgbacache is None:
- x = self.to_rgba(self._A, self._alpha)
- self._rgbacache = x
- else:
- x = self._rgbacache
- im = _image.fromarray(x[yslice,xslice], 0)
- if len(self._A.shape) == 2:
- im.is_grayscale = self.cmap.is_gray()
- else:
- im.is_grayscale = False
- self._imcache = im
-
- if self.origin=='upper':
- im.flipud_in()
- else:
- im = self._imcache
-
fc = self.axes.patch.get_facecolor()
bg = mcolors.colorConverter.to_rgba(fc, 0)
im.set_bg( *bg)
@@ -435,6 +491,15 @@
return im
+ def _check_unsampled_image(self, renderer):
+ """
+ return True if the image is better to be drawn unsampled.
+ """
+ if renderer.option_scale_image() and self.get_interpolation() == "nearest":
+ return True
+ else:
+ return False
+
def set_extent(self, extent):
"""
extent is data axes (left, right, bottom, top) for making image plots
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2009-12-15 02:57:56
|
Revision: 8034
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8034&view=rev
Author: astraw
Date: 2009-12-15 02:57:46 +0000 (Tue, 15 Dec 2009)
Log Message:
-----------
Add patch_artist kwarg to boxplot
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/examples/pylab_examples/boxplot_demo2.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/pyplot.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-12-15 02:57:32 UTC (rev 8033)
+++ trunk/matplotlib/CHANGELOG 2009-12-15 02:57:46 UTC (rev 8034)
@@ -1,3 +1,6 @@
+2009-12-14 Add patch_artist kwarg to boxplot, but keep old default.
+ Convert boxplot_demo2.py to use the new patch_artist. - ADS
+
2009-12-06 axes_grid: reimplemented AxisArtist with FloatingAxes support.
Added new examples. - JJL
Modified: trunk/matplotlib/examples/pylab_examples/boxplot_demo2.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/boxplot_demo2.py 2009-12-15 02:57:32 UTC (rev 8033)
+++ trunk/matplotlib/examples/pylab_examples/boxplot_demo2.py 2009-12-15 02:57:46 UTC (rev 8034)
@@ -42,8 +42,8 @@
ax1 = fig.add_subplot(111)
plt.subplots_adjust(left=0.075, right=0.95, top=0.9, bottom=0.25)
-bp = plt.boxplot(data, notch=0, sym='+', vert=1, whis=1.5)
-plt.setp(bp['boxes'], color='black')
+bp = plt.boxplot(data, notch=0, sym='+', vert=1, whis=1.5, patch_artist=True)
+plt.setp(bp['boxes'], edgecolor='black')
plt.setp(bp['whiskers'], color='black')
plt.setp(bp['fliers'], color='red', marker='+')
@@ -64,25 +64,12 @@
medians = range(numBoxes)
for i in range(numBoxes):
box = bp['boxes'][i]
- boxX = []
- boxY = []
- for j in range(5):
- boxX.append(box.get_xdata()[j])
- boxY.append(box.get_ydata()[j])
- boxCoords = zip(boxX,boxY)
- # Alternate between Dark Khaki and Royal Blue
k = i % 2
- boxPolygon = Polygon(boxCoords, facecolor=boxColors[k])
- ax1.add_patch(boxPolygon)
- # Now draw the median lines back over what we just filled in
+ # Set the box colors
+ box.set_facecolor(boxColors[k])
+ # Now get the medians
med = bp['medians'][i]
- medianX = []
- medianY = []
- for j in range(2):
- medianX.append(med.get_xdata()[j])
- medianY.append(med.get_ydata()[j])
- plt.plot(medianX, medianY, 'k')
- medians[i] = medianY[0]
+ medians[i] = med.get_ydata()[0]
# Finally, overplot the sample averages, with horixzontal alignment
# in the center of each box
plt.plot([np.average(med.get_xdata())], [np.average(data[i])],
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-12-15 02:57:32 UTC (rev 8033)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-12-15 02:57:46 UTC (rev 8034)
@@ -21,6 +21,7 @@
import matplotlib.legend as mlegend
import matplotlib.lines as mlines
import matplotlib.mlab as mlab
+import matplotlib.path as mpath
import matplotlib.patches as mpatches
import matplotlib.spines as mspines
import matplotlib.quiver as mquiver
@@ -4892,12 +4893,12 @@
return (l0, caplines, barcols)
def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5,
- positions=None, widths=None):
+ positions=None, widths=None, patch_artist=False):
"""
call signature::
boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
- positions=None, widths=None)
+ positions=None, widths=None, patch_artist=False)
Make a box and whisker plot for each column of *x* or each
vector in sequence *x*. The box extends from the lower to
@@ -4905,6 +4906,8 @@
The whiskers extend from the box to show the range of the
data. Flier points are those past the end of the whiskers.
+ *x* is an array or a sequence of vectors.
+
- *notch* = 0 (default) produces a rectangular box plot.
- *notch* = 1 will produce a notched box plot
@@ -4927,7 +4930,8 @@
each box. The default is 0.5, or ``0.15*(distance between extreme
positions)`` if that is smaller.
- *x* is an array or a sequence of vectors.
+ - *patch_artist* = False (default) produces boxes with the Line2D artist
+ - *patch_artist* = True produces boxes with the Patch artist
Returns a dictionary mapping each component of the boxplot
to a list of the :class:`matplotlib.lines.Line2D`
@@ -5045,23 +5049,55 @@
med_x = [cap_x_min, cap_x_max]
med_y = [med, med]
+ def to_vc(xs,ys):
+ # convert arguments to verts and codes
+ verts = []
+ #codes = []
+ for xi,yi in zip(xs,ys):
+ verts.append( (xi,yi) )
+ verts.append( (0,0) ) # ignored
+ codes = [mpath.Path.MOVETO] + \
+ [mpath.Path.LINETO]*(len(verts)-2) + \
+ [mpath.Path.CLOSEPOLY]
+ return verts,codes
+
+ def patch_list(xs,ys):
+ verts,codes = to_vc(xs,ys)
+ path = mpath.Path( verts, codes )
+ patch = mpatches.PathPatch(path)
+ self.add_artist(patch)
+ return [patch]
+
# vertical or horizontal plot?
if vert:
def doplot(*args):
return self.plot(*args)
+ def dopatch(xs,ys):
+ return patch_list(xs,ys)
else:
def doplot(*args):
shuffled = []
for i in xrange(0, len(args), 3):
shuffled.extend([args[i+1], args[i], args[i+2]])
return self.plot(*shuffled)
+ def dopatch(xs,ys):
+ xs,ys = ys,xs # flip X, Y
+ return patch_list(xs,ys)
+ if patch_artist:
+ median_color = 'k'
+ else:
+ median_color = 'r'
+
whiskers.extend(doplot(wisk_x, [q1, wisk_lo], 'b--',
wisk_x, [q3, wisk_hi], 'b--'))
caps.extend(doplot(cap_x, [wisk_hi, wisk_hi], 'k-',
cap_x, [wisk_lo, wisk_lo], 'k-'))
- boxes.extend(doplot(box_x, box_y, 'b-'))
- medians.extend(doplot(med_x, med_y, 'r-'))
+ if patch_artist:
+ boxes.extend(dopatch(box_x, box_y))
+ else:
+ boxes.extend(doplot(box_x, box_y, 'b-'))
+ medians.extend(doplot(med_x, med_y, median_color+'-'))
fliers.extend(doplot(flier_hi_x, flier_hi, sym,
flier_lo_x, flier_lo, sym))
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2009-12-15 02:57:32 UTC (rev 8033)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2009-12-15 02:57:46 UTC (rev 8034)
@@ -1767,7 +1767,8 @@
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
@autogen_docstring(Axes.boxplot)
-def boxplot(x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None, hold=None):
+def boxplot(x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None,
+ hold=None, patch_artist=False):
ax = gca()
# allow callers to override the hold state by passing hold=True|False
washold = ax.ishold()
@@ -1775,7 +1776,8 @@
if hold is not None:
ax.hold(hold)
try:
- ret = ax.boxplot(x, notch, sym, vert, whis, positions, widths)
+ ret = ax.boxplot(x, notch, sym, vert, whis, positions, widths,
+ patch_artist=patch_artist)
draw_if_interactive()
finally:
ax.hold(washold)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2009-12-15 02:57:40
|
Revision: 8033
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8033&view=rev
Author: astraw
Date: 2009-12-15 02:57:32 +0000 (Tue, 15 Dec 2009)
Log Message:
-----------
boxplot demo 2: set random seed so plots are identical
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/boxplot_demo2.py
Modified: trunk/matplotlib/examples/pylab_examples/boxplot_demo2.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/boxplot_demo2.py 2009-12-13 21:03:44 UTC (rev 8032)
+++ trunk/matplotlib/examples/pylab_examples/boxplot_demo2.py 2009-12-15 02:57:32 UTC (rev 8033)
@@ -16,6 +16,9 @@
randomDists = ['Normal(1,1)',' Lognormal(1,1)', 'Exp(1)', 'Gumbel(6,4)',
'Triangular(2,9,11)']
N = 500
+
+np.random.seed(3) # make identical plots each time
+
norm = np.random.normal(1,1, N)
logn = np.random.lognormal(1,1, N)
expo = np.random.exponential(1, N)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-12-13 21:03:55
|
Revision: 8032
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8032&view=rev
Author: leejjoon
Date: 2009-12-13 21:03:44 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
fix wrong tick direction at the boudary of floating axes
Modified Paths:
--------------
trunk/matplotlib/lib/mpl_toolkits/axes_grid/floating_axes.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/floating_axes.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/floating_axes.py 2009-12-13 21:02:05 UTC (rev 8031)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/floating_axes.py 2009-12-13 21:03:44 UTC (rev 8032)
@@ -12,7 +12,7 @@
from mpl_toolkits.axes_grid.axislines import AxisArtistHelper, GridHelperBase
from mpl_toolkits.axes_grid.axis_artist import AxisArtist
-from matplotlib.transforms import Affine2D
+from matplotlib.transforms import Affine2D, IdentityTransform
import numpy as np
@@ -85,7 +85,7 @@
def get_tick_transform(self, axes):
- return axes.transData
+ return IdentityTransform() #axes.transData
def get_tick_iterators(self, axes):
"""tick_loc, tick_angle, tick_label, (optionally) tick_label"""
@@ -99,17 +99,17 @@
lon_levs, lat_levs = np.asarray(lon_levs), np.asarray(lat_levs)
if lat_factor is not None:
yy0 = lat_levs / lat_factor
- dy = 0.01 / lat_factor
+ dy = 0.001 / lat_factor
else:
yy0 = lat_levs
- dy = 0.01
+ dy = 0.001
if lon_factor is not None:
xx0 = lon_levs / lon_factor
- dx = 0.01 / lon_factor
+ dx = 0.001 / lon_factor
else:
xx0 = lon_levs
- dx = 0.01
+ dx = 0.001
_extremes = self.grid_helper._extremes
xmin, xmax = sorted(_extremes[:2])
@@ -121,30 +121,60 @@
mask = (xmin <= xx0) & (xx0 <= xmax)
xx0 = xx0[mask]
+ def transform_xy(x, y):
+ x1, y1 = grid_finder.transform_xy(x, y)
+ x2y2 = axes.transData.transform(np.array([x1, y1]).transpose())
+ x2, y2 = x2y2.transpose()
+ return x2, y2
+
# find angles
if self.nth_coord == 0:
xx0 = np.empty_like(yy0)
xx0.fill(self.value)
- xx1, yy1 = grid_finder.transform_xy(xx0, yy0)
- xx2, yy2 = grid_finder.transform_xy(xx0+dx, yy0)
- xx3, yy3 = grid_finder.transform_xy(xx0, yy0+dy)
+
+ #yy0_ = yy0.copy()
+
+ xx1, yy1 = transform_xy(xx0, yy0)
+
+ xx00 = xx0.copy()
+ xx00[xx0+dx>xmax] -= dx
+ xx1a, yy1a = transform_xy(xx00, yy0)
+ xx1b, yy1b = transform_xy(xx00+dx, yy0)
+
+ yy00 = yy0.copy()
+ yy00[yy0+dy>ymax] -= dy
+ xx2a, yy2a = transform_xy(xx0, yy00)
+ xx2b, yy2b = transform_xy(xx0, yy00+dy)
+
labels = self.grid_info["lat_labels"]
labels = [l for l, m in zip(labels, mask) if m]
elif self.nth_coord == 1:
yy0 = np.empty_like(xx0)
yy0.fill(self.value)
- xx1, yy1 = grid_finder.transform_xy(xx0, yy0)
- xx2, yy2 = grid_finder.transform_xy(xx0, yy0+dy)
- xx3, yy3 = grid_finder.transform_xy(xx0+dx, yy0)
+
+ #xx0_ = xx0.copy()
+ xx1, yy1 = transform_xy(xx0, yy0)
+
+
+ yy00 = yy0.copy()
+ yy00[yy0+dy>ymax] -= dy
+ xx1a, yy1a = transform_xy(xx0, yy00)
+ xx1b, yy1b = transform_xy(xx0, yy00+dy)
+
+ xx00 = xx0.copy()
+ xx00[xx0+dx>xmax] -= dx
+ xx2a, yy2a = transform_xy(xx00, yy0)
+ xx2b, yy2b = transform_xy(xx00+dx, yy0)
+
labels = self.grid_info["lon_labels"]
labels = [l for l, m in zip(labels, mask) if m]
def f1():
- dd = np.arctan2(yy2-yy1, xx2-xx1) # angle normal
- dd2 = np.arctan2(yy3-yy1, xx3-xx1) # angle tangent
- mm = ((yy2-yy1)==0.) & ((xx2-xx1)==0.) # mask where dd1 is not defined
+ dd = np.arctan2(yy1b-yy1a, xx1b-xx1a) # angle normal
+ dd2 = np.arctan2(yy2b-yy2a, xx2b-xx2a) # angle tangent
+ mm = ((yy1b-yy1a)==0.) & ((xx1b-xx1a)==0.) # mask where dd1 is not defined
dd[mm] = dd2[mm]+3.14159/2.
#dd += 3.14159
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py 2009-12-13 21:02:05 UTC (rev 8031)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py 2009-12-13 21:03:44 UTC (rev 8032)
@@ -8,7 +8,7 @@
from mpl_toolkits.axes_grid.axislines import \
AxisArtistHelper, GridHelperBase
from mpl_toolkits.axes_grid.axis_artist import AxisArtist
-from matplotlib.transforms import Affine2D
+from matplotlib.transforms import Affine2D, IdentityTransform
import numpy as np
class FixedAxisArtistHelper(AxisArtistHelper.Fixed):
@@ -172,7 +172,7 @@
def get_tick_transform(self, axes):
- return axes.transData
+ return IdentityTransform() #axes.transData
def get_tick_iterators(self, axes):
"""tick_loc, tick_angle, tick_label, (optionally) tick_label"""
@@ -212,31 +212,57 @@
#xx0, yy0 = xx0[mask], yy0[mask]
xx0 = xx0[mask]
+ def transform_xy(x, y):
+ x1, y1 = grid_finder.transform_xy(x, y)
+ x2y2 = axes.transData.transform(np.array([x1, y1]).transpose())
+ x2, y2 = x2y2.transpose()
+ return x2, y2
+
# find angles
if self.nth_coord == 0:
xx0 = np.empty_like(yy0)
xx0.fill(self.value)
- xx1, yy1 = grid_finder.transform_xy(xx0, yy0)
- xx2, yy2 = grid_finder.transform_xy(xx0+dx, yy0)
- xx3, yy3 = grid_finder.transform_xy(xx0, yy0+dy)
+
+ xx1, yy1 = transform_xy(xx0, yy0)
+
+ xx00 = xx0.copy()
+ xx00[xx0+dx>e1] -= dx
+ xx1a, yy1a = transform_xy(xx00, yy0)
+ xx1b, yy1b = transform_xy(xx00+dx, yy0)
+
+ xx2a, yy2a = transform_xy(xx0, yy0)
+ xx2b, yy2b = transform_xy(xx0, yy0+dy)
+
labels = self.grid_info["lat_labels"]
labels = [l for l, m in zip(labels, mask) if m]
elif self.nth_coord == 1:
yy0 = np.empty_like(xx0)
yy0.fill(self.value)
- xx1, yy1 = grid_finder.transform_xy(xx0, yy0)
- xx2, yy2 = grid_finder.transform_xy(xx0, yy0+dy)
- xx3, yy3 = grid_finder.transform_xy(xx0+dx, yy0)
+
+ xx1, yy1 = transform_xy(xx0, yy0)
+
+ xx1a, yy1a = transform_xy(xx0, yy0)
+ xx1b, yy1b = transform_xy(xx0, yy0+dy)
+
+ xx00 = xx0.copy()
+ xx00[xx0+dx>e1] -= dx
+ xx2a, yy2a = transform_xy(xx00, yy0)
+ xx2b, yy2b = transform_xy(xx00+dx, yy0)
+
labels = self.grid_info["lon_labels"]
labels = [l for l, m in zip(labels, mask) if m]
def f1():
- dd = np.arctan2(yy2-yy1, xx2-xx1) # angle normal
- dd2 = np.arctan2(yy3-yy1, xx3-xx1) # angle tangent
- mm = ((yy2-yy1)==0.) & ((xx2-xx1)==0.) # mask where dd1 is not defined
+ dd = np.arctan2(yy1b-yy1a, xx1b-xx1a) # angle normal
+ dd2 = np.arctan2(yy2b-yy2a, xx2b-xx2a) # angle tangent
+ mm = ((yy1b-yy1a)==0.) & ((xx1b-xx1a)==0.) # mask where dd1 is not defined
dd[mm] = dd2[mm]+3.14159/2.
+ #dd = np.arctan2(yy2-yy1, xx2-xx1) # angle normal
+ #dd2 = np.arctan2(yy3-yy1, xx3-xx1) # angle tangent
+ #mm = ((yy2-yy1)==0.) & ((xx2-xx1)==0.) # mask where dd1 is not defined
+ #dd[mm] = dd2[mm]+3.14159/2.
#dd += 3.14159
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-12-13 21:02:39
|
Revision: 8031
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8031&view=rev
Author: leejjoon
Date: 2009-12-13 21:02:05 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
update demo_floating_axes.py
Modified Paths:
--------------
trunk/matplotlib/examples/axes_grid/demo_floating_axes.py
Modified: trunk/matplotlib/examples/axes_grid/demo_floating_axes.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/demo_floating_axes.py 2009-12-13 20:24:23 UTC (rev 8030)
+++ trunk/matplotlib/examples/axes_grid/demo_floating_axes.py 2009-12-13 21:02:05 UTC (rev 8031)
@@ -10,7 +10,28 @@
DictFormatter
def setup_axes1(fig, rect):
+ """
+ A simple one.
+ """
+ tr = Affine2D().scale(2, 1).rotate_deg(30)
+ grid_helper = GridHelperCurveLinear(tr, extremes=(0, 4, 0, 4))
+
+ ax1 = FloatingSubplot(fig, rect, grid_helper=grid_helper)
+ fig.add_subplot(ax1)
+
+ grid_helper.grid_finder.grid_locator1._nbins = 4
+ grid_helper.grid_finder.grid_locator2._nbins = 4
+
+ return ax1
+
+
+def setup_axes2(fig, rect):
+ """
+ With custom locator and formatter.
+ Note that the extreme values are swapped.
+ """
+
#tr_scale = Affine2D().scale(np.pi/180., 1.)
tr = PolarAxes.PolarTransform()
@@ -26,8 +47,6 @@
grid_helper = GridHelperCurveLinear(tr,
extremes=(.5*pi, 0, 2, 1),
- #extremes=(0, .5*pi, 1, 2),
- #extremes=(0, 1, 1, 2),
grid_locator1=grid_locator1,
grid_locator2=grid_locator2,
tick_formatter1=tick_formatter1,
@@ -37,8 +56,6 @@
ax1 = FloatingSubplot(fig, rect, grid_helper=grid_helper)
fig.add_subplot(ax1)
- #ax1.axis[:]
-
# create a parasite axes whose transData in RA, cz
aux_ax = ax1.get_aux_axes(tr)
@@ -51,7 +68,10 @@
return ax1, aux_ax
-def setup_axes2(fig, rect):
+def setup_axes3(fig, rect):
+ """
+ Sometimes, things like axis_direction need to be adjusted.
+ """
# rotate a bit for better orientation
tr_rotate = Affine2D().translate(-95, 0)
@@ -105,26 +125,31 @@
return ax1, aux_ax
-def sixty(d, m, s):
- return d + (m + s/60.)/60.
-
-
if 1:
import matplotlib.pyplot as plt
- fig = plt.figure(1, figsize=(7, 5))
+ fig = plt.figure(1, figsize=(8, 4))
+ fig.subplots_adjust(wspace=0.3, left=0.05, right=0.95)
- ax1, aux_ax1 = setup_axes1(fig, 121)
+ ax1 = setup_axes1(fig, 131)
+ #theta = np.random.rand(10) #*.5*np.pi
+ #radius = np.random.rand(10) #+1.
+ #aux_ax1.scatter(theta, radius)
+
+
+ ax2, aux_ax2 = setup_axes2(fig, 132)
+
theta = np.random.rand(10)*.5*np.pi
radius = np.random.rand(10)+1.
- aux_ax1.scatter(theta, radius)
+ aux_ax2.scatter(theta, radius)
- ax2, aux_ax2 = setup_axes2(fig, 122)
+ ax3, aux_ax3 = setup_axes3(fig, 133)
+
theta = (8 + np.random.rand(10)*(14-8))*15. # indegree
radius = np.random.rand(10)*14000.
- aux_ax2.scatter(theta, radius)
+ aux_ax3.scatter(theta, radius)
plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-12-13 20:43:23
|
Revision: 8029
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8029&view=rev
Author: jouni
Date: 2009-12-13 19:59:15 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
Fix figimage test to really exercise both branches in figure.draw
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/tests/test_image.py
Modified: trunk/matplotlib/lib/matplotlib/tests/test_image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_image.py 2009-12-13 19:28:22 UTC (rev 8028)
+++ trunk/matplotlib/lib/matplotlib/tests/test_image.py 2009-12-13 19:59:15 UTC (rev 8029)
@@ -35,16 +35,16 @@
for suppressComposite in False, True:
fig = plt.figure(figsize=(2,2), dpi=100)
- fig.suppressComposite=suppressComposite
+ fig.suppressComposite = suppressComposite
x,y = np.ix_(np.arange(100.0)/100.0, np.arange(100.0)/100.0)
z = np.sin(x**2 + y**2 - x*y)
c = np.sin(20*x**2 + 50*y**2)
img = z + c/5
fig.figimage(img, xo=0, yo=0, origin='lower')
- fig.figimage(img, xo=0, yo=100, origin='upper')
+ fig.figimage(img[::-1,:], xo=0, yo=100, origin='lower')
fig.figimage(img[:,::-1], xo=100, yo=0, origin='lower')
- fig.figimage(img[:,::-1], xo=100, yo=100, origin='upper')
+ fig.figimage(img[::-1,::-1], xo=100, yo=100, origin='lower')
fig.savefig('figimage-%d' % int(suppressComposite), dpi=100)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-12-13 20:24:32
|
Revision: 8030
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8030&view=rev
Author: jouni
Date: 2009-12-13 20:24:23 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
Fix AttributeError in figure.draw when compositing images
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2009-12-13 19:59:15 UTC (rev 8029)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2009-12-13 20:24:23 UTC (rev 8030)
@@ -755,11 +755,12 @@
# override the renderer default if self.suppressComposite
# is not None
- composite = renderer.option_image_nocomposite()
+ not_composite = renderer.option_image_nocomposite()
if self.suppressComposite is not None:
- composite = self.suppressComposite
+ not_composite = self.suppressComposite
- if len(self.images)<=1 or composite or not allequal([im.origin for im in self.images]):
+ if len(self.images)<=1 or not_composite or \
+ not allequal([im.origin for im in self.images]):
for a in self.images:
dsu.append( (a.get_zorder(), a.draw, [renderer]))
else:
@@ -783,8 +784,7 @@
renderer.draw_image(gc, l, b, im)
gc.restore()
- if len(ims):
- dsu.append((ims[0].get_zorder(), draw_composite, []))
+ dsu.append((self.images[0].get_zorder(), draw_composite, []))
# render the axes
for a in self.axes:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-12-13 19:28:29
|
Revision: 8028
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8028&view=rev
Author: jouni
Date: 2009-12-13 19:28:22 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
Add baseline images for figimage test
Added Paths:
-----------
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_image/figimage-0.png
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_image/figimage-1.png
Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_image/figimage-0.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_image/figimage-0.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_image/figimage-1.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_image/figimage-1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-12-13 19:19:35
|
Revision: 8027
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8027&view=rev
Author: jouni
Date: 2009-12-13 19:19:28 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
Add test for figimage bug
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/tests/test_image.py
Modified: trunk/matplotlib/lib/matplotlib/tests/test_image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_image.py 2009-12-13 12:06:07 UTC (rev 8026)
+++ trunk/matplotlib/lib/matplotlib/tests/test_image.py 2009-12-13 19:19:28 UTC (rev 8027)
@@ -29,6 +29,25 @@
fig.savefig('image_interps')
+@image_comparison(baseline_images=['figimage-0', 'figimage-1'], extensions=['png'])
+def test_figimage():
+ 'test the figimage method'
+
+ for suppressComposite in False, True:
+ fig = plt.figure(figsize=(2,2), dpi=100)
+ fig.suppressComposite=suppressComposite
+ x,y = np.ix_(np.arange(100.0)/100.0, np.arange(100.0)/100.0)
+ z = np.sin(x**2 + y**2 - x*y)
+ c = np.sin(20*x**2 + 50*y**2)
+ img = z + c/5
+
+ fig.figimage(img, xo=0, yo=0, origin='lower')
+ fig.figimage(img, xo=0, yo=100, origin='upper')
+ fig.figimage(img[:,::-1], xo=100, yo=0, origin='lower')
+ fig.figimage(img[:,::-1], xo=100, yo=100, origin='upper')
+
+ fig.savefig('figimage-%d' % int(suppressComposite), dpi=100)
+
def test_image_python_io():
fig = plt.figure()
ax = fig.add_subplot(111)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-12-13 12:06:16
|
Revision: 8026
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8026&view=rev
Author: jouni
Date: 2009-12-13 12:06:07 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
Address mathtext problem with non-BMP characters: http://thread.gmane.org/gmane.comp.python.matplotlib.general/19963/focus=19978
Modified Paths:
--------------
trunk/matplotlib/doc/users/mathtext.rst
trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/doc/users/mathtext.rst
===================================================================
--- trunk/matplotlib/doc/users/mathtext.rst 2009-12-12 18:24:54 UTC (rev 8025)
+++ trunk/matplotlib/doc/users/mathtext.rst 2009-12-13 12:06:07 UTC (rev 8026)
@@ -23,6 +23,13 @@
customization variable ``mathtext.fontset`` (see
:ref:`customizing-matplotlib`)
+.. note::
+ On `"narrow" <http://wordaligned.org/articles/narrow-python>`_ builds
+ of Python, if you use the STIX fonts you should also set
+ ``ps.fonttype`` and ``pdf.fonttype`` to 3 (the default), not 42.
+ Otherwise `some characters will not be visible
+ <http://thread.gmane.org/gmane.comp.python.matplotlib.general/19963/focus=19978>`_.
+
Here is a simple example::
# plain text
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2009-12-12 18:24:54 UTC (rev 8025)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2009-12-13 12:06:07 UTC (rev 8026)
@@ -82,6 +82,14 @@
TeX/Type1 symbol"""%locals()
raise ValueError, message
+def unichr_safe(index):
+ """Return the Unicode character corresponding to the index,
+or the replacement character if this is a narrow build of Python
+and the requested character is outside the BMP."""
+ try:
+ return unichr(index)
+ except ValueError:
+ return unichr(0xFFFD)
class MathtextBackend(object):
"""
@@ -321,7 +329,8 @@
def render_glyph(self, ox, oy, info):
oy = self.height - oy + info.offset
- thetext = unichr(info.num)
+ thetext = unichr_safe(info.num)
+
self.svg_glyphs.append(
(info.font, info.fontsize, thetext, ox, oy, info.metrics))
@@ -351,7 +360,7 @@
def render_glyph(self, ox, oy, info):
oy = self.height - oy + info.offset
- thetext = unichr(info.num)
+ thetext = unichr_safe(info.num)
self.glyphs.append(
(info.font, info.fontsize, thetext, ox, oy))
@@ -379,7 +388,7 @@
def render_glyph(self, ox, oy, info):
oy = oy - info.offset - self.height
- thetext = unichr(info.num)
+ thetext = unichr_safe(info.num)
self.glyphs.append(
(info.font, info.fontsize, thetext, ox, oy))
@@ -997,7 +1006,7 @@
cached_font = self._get_font(i)
glyphindex = cached_font.charmap.get(uniindex)
if glyphindex is not None:
- alternatives.append((i, unichr(uniindex)))
+ alternatives.append((i, unichr_safe(uniindex)))
# The largest size of the radical symbol in STIX has incorrect
# metrics that cause it to be disconnected from the stem.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-12-12 18:25:04
|
Revision: 8025
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8025&view=rev
Author: jswhit
Date: 2009-12-12 18:24:54 +0000 (Sat, 12 Dec 2009)
Log Message:
-----------
more fixes for computation of lonmin, lonmax
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-12 14:18:30 UTC (rev 8024)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-12 18:24:54 UTC (rev 8025)
@@ -733,28 +733,6 @@
self.llcrnry = proj.llcrnry
self.urcrnrx = proj.urcrnrx
self.urcrnry = proj.urcrnry
- # set min/max lats for projection domain.
- if projection in _cylproj:
- self.latmin = self.llcrnrlat
- self.latmax = self.urcrnrlat
- self.lonmin = self.llcrnrlon
- self.lonmax = self.urcrnrlon
- elif projection in ['ortho','geos'] + _pseudocyl:
- self.latmin = -90.
- self.latmax = 90.
- self.lonmin = self.llcrnrlon
- self.lonmax = self.urcrnrlon
- else:
- lons, lats = self.makegrid(1001,1001)
- self.latmin = lats.min()
- self.latmax = lats.max()
- self.lonmin = lons.min()
- self.lonmax = lons.max()
- # projection crosses dateline.
- if self.lonmin < 0 and self.lonmax > 0.:
- lons = np.where(lons < 0, lons+360, lons)
- self.lonmin = lons.min()
- self.lonmax = lons.max()
# if ax == None, pyplot.gca may be used.
self.ax = ax
@@ -778,6 +756,38 @@
self.area_thresh = area_thresh
# define map boundary polygon (in lat/lon coordinates)
self._boundarypolyll, self._boundarypolyxy = self._getmapboundary()
+ # set min/max lats for projection domain.
+ if self.projection in _cylproj:
+ self.latmin = self.llcrnrlat
+ self.latmax = self.urcrnrlat
+ self.lonmin = self.llcrnrlon
+ self.lonmax = self.urcrnrlon
+ elif self.projection in ['ortho','geos'] + _pseudocyl:
+ self.latmin = -90.
+ self.latmax = 90.
+ self.lonmin = self.llcrnrlon
+ self.lonmax = self.urcrnrlon
+ else:
+ lons, lats = self.makegrid(1001,1001)
+ self.latmin = lats.min()
+ self.latmax = lats.max()
+ self.lonmin = lons.min()
+ self.lonmax = lons.max()
+ NPole = _geoslib.Point(self(0.,90.))
+ SPole = _geoslib.Point(self(0.,-90.))
+ Dateline = _geoslib.Point(self(180.,lat_0))
+ Greenwich = _geoslib.Point(self(0.,lat_0))
+ hasNP = NPole.within(self._boundarypolyxy)
+ hasSP = SPole.within(self._boundarypolyxy)
+ hasPole = hasNP or hasSP
+ hasDateline = Dateline.within(self._boundarypolyxy)
+ hasGreenwich = Greenwich.within(self._boundarypolyxy)
+ # projection crosses dateline (and not Greenwich or pole).
+ if not hasPole and hasDateline and not hasGreenwich:
+ if self.lonmin < 0 and self.lonmax > 0.:
+ lons = np.where(lons < 0, lons+360, lons)
+ self.lonmin = lons.min()
+ self.lonmax = lons.max()
# read in coastline polygons, only keeping those that
# intersect map boundary polygon.
if self.resolution is not None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-12-12 14:18:38
|
Revision: 8024
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8024&view=rev
Author: jswhit
Date: 2009-12-12 14:18:30 +0000 (Sat, 12 Dec 2009)
Log Message:
-----------
fix ambiguity in lonmin, lonmax when projection crosses dateline.
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-11 16:57:53 UTC (rev 8023)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-12 14:18:30 UTC (rev 8024)
@@ -750,6 +750,11 @@
self.latmax = lats.max()
self.lonmin = lons.min()
self.lonmax = lons.max()
+ # projection crosses dateline.
+ if self.lonmin < 0 and self.lonmax > 0.:
+ lons = np.where(lons < 0, lons+360, lons)
+ self.lonmin = lons.min()
+ self.lonmax = lons.max()
# if ax == None, pyplot.gca may be used.
self.ax = ax
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-12-11 16:58:01
|
Revision: 8023
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8023&view=rev
Author: leejjoon
Date: 2009-12-11 16:57:53 +0000 (Fri, 11 Dec 2009)
Log Message:
-----------
add ArrowStyle |-|
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/fancyarrow_demo.py
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/examples/pylab_examples/fancyarrow_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fancyarrow_demo.py 2009-12-11 16:57:46 UTC (rev 8022)
+++ trunk/matplotlib/examples/pylab_examples/fancyarrow_demo.py 2009-12-11 16:57:53 UTC (rev 8023)
@@ -4,7 +4,7 @@
styles = mpatches.ArrowStyle.get_styles()
ncol=2
-nrow = len(styles) // ncol + 1
+nrow = (len(styles)+1) // ncol
figheight = (nrow+0.5)
fig1 = plt.figure(1, (4.*ncol/1.5, figheight/1.5))
fontsize = 0.2 * 70
@@ -15,13 +15,19 @@
ax.set_xlim(0, 4*ncol)
ax.set_ylim(0, figheight)
+def to_texstring(s):
+ s = s.replace("<", r"$<$")
+ s = s.replace(">", r"$>$")
+ s = s.replace("|", r"$|$")
+ return s
+
for i, (stylename, styleclass) in enumerate(sorted(styles.items())):
x = 3.2 + (i//nrow)*4
y = (figheight - 0.7 - i%nrow) # /figheight
p = mpatches.Circle((x, y), 0.2, fc="w")
ax.add_patch(p)
- ax.annotate(stylename, (x, y),
+ ax.annotate(to_texstring(stylename), (x, y),
(x-1.2, y),
#xycoords="figure fraction", textcoords="figure fraction",
ha="right", va="center",
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-12-11 16:57:46 UTC (rev 8022)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-12-11 16:57:53 UTC (rev 8023)
@@ -3299,6 +3299,41 @@
_style_list["-["] = BracketB
+ class BarAB(_Bracket):
+ """
+ An arrow with a bracket(]) at both ends.
+ """
+
+ def __init__(self,
+ widthA=1., angleA=None,
+ widthB=1., angleB=None):
+ """
+ *widthA*
+ width of the bracket
+
+ *lengthA*
+ length of the bracket
+
+ *angleA*
+ angle between the bracket and the line
+
+ *widthB*
+ width of the bracket
+
+ *lengthB*
+ length of the bracket
+
+ *angleB*
+ angle between the bracket and the line
+ """
+
+ super(ArrowStyle.BarAB, self).__init__(True, True, \
+ widthA=widthA, lengthA=0, angleA=angleA,
+ widthB=widthB, lengthB=0, angleB=angleB)
+
+ _style_list["|-|"] = BarAB
+
+
class Simple(_Base):
"""
A simple arrow. Only works with a quadratic bezier curve.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-12-11 16:57:53
|
Revision: 8022
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8022&view=rev
Author: leejjoon
Date: 2009-12-11 16:57:46 +0000 (Fri, 11 Dec 2009)
Log Message:
-----------
Axes.draw rearranged to support rasterization
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-12-11 00:59:34 UTC (rev 8021)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-12-11 16:57:46 UTC (rev 8022)
@@ -30,6 +30,8 @@
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms
+from operator import itemgetter
+
iterable = cbook.iterable
is_string_like = cbook.is_string_like
is_sequence_of_strings = cbook.is_sequence_of_strings
@@ -1698,11 +1700,22 @@
artists.extend(self.spines.itervalues())
+
dsu = [ (a.zorder, a) for a in artists
if not a.get_animated() ]
- dsu.sort(key=lambda x: x[0])
+ # add images to dsu if the backend support compositing.
+ # otherwise, does the manaul compositing without adding images to dsu.
+ if len(self.images)<=1 or renderer.option_image_nocomposite():
+ dsu.extend([(im.zorder, im) for im in self.images])
+ _do_composite = False
+ else:
+ _do_composite = True
+
+
+ dsu.sort(key=itemgetter(0))
+
# rasterize artists with negative zorder
# if the minimum zorder is negative, start rasterization
rasterization_zorder = self._rasterization_zorder
@@ -1719,11 +1732,7 @@
if self.axison and self._frameon:
self.patch.draw(renderer)
- if len(self.images)<=1 or renderer.option_image_nocomposite():
- for im in self.images:
- dsu.append( (im.zorder, im) )
- dsu.sort(key=lambda x: x[0]) # re-sort with images now
- else:
+ if _do_composite:
# make a composite image blending alpha
# list of (mimage.Image, ox, oy)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2009-12-11 00:59:44
|
Revision: 8021
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8021&view=rev
Author: astraw
Date: 2009-12-11 00:59:34 +0000 (Fri, 11 Dec 2009)
Log Message:
-----------
rec2csv raises explicit error when recarray ndim not 1
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/mlab.py
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2009-12-11 00:59:25 UTC (rev 8020)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2009-12-11 00:59:34 UTC (rev 8021)
@@ -2598,6 +2598,9 @@
return func(val)
return newfunc
+ if r.ndim != 1:
+ raise ValueError('rec2csv only operates on 1 dimensional recarrays')
+
formatd = get_formatd(r, formatd)
funcs = []
for i, name in enumerate(r.dtype.names):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2009-12-11 00:59:37
|
Revision: 8020
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8020&view=rev
Author: astraw
Date: 2009-12-11 00:59:25 +0000 (Fri, 11 Dec 2009)
Log Message:
-----------
tests: add tests for rec2csv and csv2rec
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/tests/test_mlab.py
Modified: trunk/matplotlib/lib/matplotlib/tests/test_mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_mlab.py 2009-12-10 23:32:41 UTC (rev 8019)
+++ trunk/matplotlib/lib/matplotlib/tests/test_mlab.py 2009-12-11 00:59:25 UTC (rev 8020)
@@ -1,5 +1,7 @@
import numpy as np
import matplotlib.mlab as mlab
+import tempfile
+from nose.tools import raises
def test_colinear_pca():
a = mlab.PCA._get_colinear()
@@ -8,3 +10,25 @@
assert(np.allclose(pca.fracs[2:], 0.))
assert(np.allclose(pca.Y[:,2:], 0.))
+def test_recarray_csv_roundtrip():
+ expected = np.recarray((99,),
+ [('x',np.float),('y',np.float),('t',np.float)])
+ expected['x'][0] = 1
+ expected['y'][1] = 2
+ expected['t'][2] = 3
+ fd = tempfile.TemporaryFile(suffix='csv')
+ mlab.rec2csv(expected,fd)
+ fd.seek(0)
+ actual = mlab.csv2rec(fd)
+ fd.close()
+ assert np.allclose( expected['x'], actual['x'] )
+ assert np.allclose( expected['y'], actual['y'] )
+ assert np.allclose( expected['t'], actual['t'] )
+
+@raises(ValueError)
+def test_rec2csv_bad_shape():
+ bad = np.recarray((99,4),[('x',np.float),('y',np.float)])
+ fd = tempfile.TemporaryFile(suffix='csv')
+
+ # the bad recarray should trigger a ValueError for having ndim > 1.
+ mlab.rec2csv(bad,fd)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2009-12-10 23:32:52
|
Revision: 8019
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8019&view=rev
Author: heeres
Date: 2009-12-10 23:32:41 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
mplot3d: support contours in directions other than z
Modified Paths:
--------------
trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py
Added Paths:
-----------
trunk/matplotlib/examples/mplot3d/contour3d_demo3.py
Added: trunk/matplotlib/examples/mplot3d/contour3d_demo3.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/contour3d_demo3.py (rev 0)
+++ trunk/matplotlib/examples/mplot3d/contour3d_demo3.py 2009-12-10 23:32:41 UTC (rev 8019)
@@ -0,0 +1,20 @@
+from mpl_toolkits.mplot3d import axes3d
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax = axes3d.Axes3D(fig)
+X, Y, Z = axes3d.get_test_data(0.05)
+ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
+cset = ax.contour(X, Y, Z, zdir='z', offset=-100)
+cset = ax.contour(X, Y, Z, zdir='x', offset=-40)
+cset = ax.contour(X, Y, Z, zdir='y', offset=40)
+
+ax.set_xlabel('X')
+ax.set_xlim3d(-40, 40)
+ax.set_ylabel('Y')
+ax.set_ylim3d(-40, 40)
+ax.set_zlabel('Z')
+ax.set_zlim3d(-100, 100)
+
+plt.show()
+
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py 2009-12-10 20:05:58 UTC (rev 8018)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py 2009-12-10 23:32:41 UTC (rev 8019)
@@ -437,9 +437,15 @@
Reorder coordinates so that zdir
"""
if zdir == 'x':
+ return ys, zs, xs
+ elif zdir == '-x':
return zs, xs, ys
+
elif zdir == 'y':
- return xs, zs, ys
+ return zs, xs, ys
+ elif zdir == '-y':
+ return ys, zs, xs
+
else:
return xs, ys, zs
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-12-10 20:05:58 UTC (rev 8018)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-12-10 23:32:41 UTC (rev 8019)
@@ -839,10 +839,11 @@
========== ================================================
*X*, *Y*, Data values as numpy.arrays
*Z*
- *levels* Number of levels to use, defaults to 10. Can
- also be a tuple of specific levels.
*extend3d* Whether to extend contour in 3D (default: False)
*stride* Stride (step size) for extending contour
+ *zdir* The direction to use: x, y or z (default)
+ *offset* If specified plot a projection of the contour
+ lines on this position in plane normal to zdir
========== ================================================
Other keyword arguments are passed on to
@@ -851,16 +852,22 @@
extend3d = kwargs.pop('extend3d', False)
stride = kwargs.pop('stride', 5)
- nlevels = kwargs.pop('nlevels', 15)
+ zdir = kwargs.pop('zdir', 'z')
+ offset = kwargs.pop('offset', None)
had_data = self.has_data()
- cset = Axes.contour(self, X, Y, Z, levels, **kwargs)
+ jX, jY, jZ = art3d.juggle_axes(X, Y, Z, zdir)
+ cset = Axes.contour(self, jX, jY, jZ, **kwargs)
+
+ zdir = '-' + zdir
if extend3d:
self._3d_extend_contour(cset, stride)
else:
for z, linec in zip(cset.levels, cset.collections):
- art3d.line_collection_2d_to_3d(linec, z)
+ if offset is not None:
+ z = offset
+ art3d.line_collection_2d_to_3d(linec, z, zdir=zdir)
self.auto_scale_xyz(X, Y, Z, had_data)
return cset
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py 2009-12-10 20:05:58 UTC (rev 8018)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py 2009-12-10 23:32:41 UTC (rev 8019)
@@ -57,11 +57,11 @@
# Some properties for the axes
_AXINFO = {
- 'x': {'i': 0, 'tickdir': 1,
+ 'x': {'i': 0, 'tickdir': 1, 'juggled': (1, 0, 2),
'color': (0.95, 0.95, 0.95, 0.5)},
- 'y': {'i': 1, 'tickdir': 0,
+ 'y': {'i': 1, 'tickdir': 0, 'juggled': (0, 1, 2),
'color': (0.90, 0.90, 0.90, 0.5)},
- 'z': {'i': 2, 'tickdir': 0,
+ 'z': {'i': 2, 'tickdir': 0, 'juggled': (0, 2, 1),
'color': (0.925, 0.925, 0.925, 0.5)},
}
@@ -191,7 +191,7 @@
minmax = np.where(highs, maxs, mins)
# Draw main axis line
- juggled = art3d.juggle_axes(0, 2, 1, self.adir)
+ juggled = info['juggled']
edgep1 = minmax.copy()
edgep1[juggled[0]] = get_flip_min_max(edgep1, juggled[0], mins, maxs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-12-10 20:06:05
|
Revision: 8018
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8018&view=rev
Author: leejjoon
Date: 2009-12-10 20:05:58 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
FancyArrowPatch.__str__ updated
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-12-10 19:05:35 UTC (rev 8017)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-12-10 20:05:58 UTC (rev 8018)
@@ -3535,9 +3535,17 @@
def __str__(self):
- return self.__class__.__name__ \
- + "FancyArrowPatch(%g,%g,%g,%g,%g,%g)" % tuple(self._q_bezier)
+
+ if self._posA_posB is not None:
+ (x1, y1), (x2, y2) = self._posA_posB
+ return self.__class__.__name__ \
+ + "(%g,%g->%g,%g)" % (x1, y1, x2, y2)
+ else:
+ return self.__class__.__name__ \
+ + "(%s)" % (str(self._path_original),)
+
+
@docstring.dedent_interpd
def __init__(self, posA=None, posB=None,
path=None,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-12-10 19:05:44
|
Revision: 8017
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8017&view=rev
Author: leejjoon
Date: 2009-12-10 19:05:35 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
add BracketAB arrow style
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-12-10 00:09:03 UTC (rev 8016)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-12-10 19:05:35 UTC (rev 8017)
@@ -3193,7 +3193,7 @@
cos_t, sin_t = get_cos_sin(x1, y1, x0, y0)
verticesA, codesA = self._get_bracket(x0, y0, cos_t, sin_t,
self.widthA*scaleA,
- self.legnthA*scaleA)
+ self.lengthA*scaleA)
vertices_list.append(verticesA)
codes_list.append(codesA)
@@ -3218,7 +3218,64 @@
return p, False
+ class BracketAB(_Bracket):
+ """
+ An arrow with a bracket(]) at both ends.
+ """
+ def __init__(self,
+ widthA=1., lengthA=0.2, angleA=None,
+ widthB=1., lengthB=0.2, angleB=None):
+ """
+ *widthA*
+ width of the bracket
+
+ *lengthA*
+ length of the bracket
+
+ *angleA*
+ angle between the bracket and the line
+
+ *widthB*
+ width of the bracket
+
+ *lengthB*
+ length of the bracket
+
+ *angleB*
+ angle between the bracket and the line
+ """
+
+ super(ArrowStyle.BracketAB, self).__init__(True, True, \
+ widthA=widthA, lengthA=lengthA, angleA=angleA,
+ widthB=widthB, lengthB=lengthB, angleB=angleB)
+
+ _style_list["]-["] = BracketAB
+
+
+ class BracketA(_Bracket):
+ """
+ An arrow with a bracket(]) at its end.
+ """
+
+ def __init__(self, widthA=1., lengthA=0.2, angleA=None):
+ """
+ *widthA*
+ width of the bracket
+
+ *lengthA*
+ length of the bracket
+
+ *angleA*
+ angle between the bracket and the line
+ """
+
+ super(ArrowStyle.BracketA, self).__init__(None, True,
+ widthA=widthA, lengthA=lengthA, angleA=angleA )
+
+ _style_list["]-"] = BracketA
+
+
class BracketB(_Bracket):
"""
An arrow with a bracket([) at its end.
@@ -3237,9 +3294,8 @@
"""
super(ArrowStyle.BracketB, self).__init__(None, True,
- widthB=widthB, lengthB=lengthB, angleB=None )
+ widthB=widthB, lengthB=lengthB, angleB=angleB )
- #_style_list["-["] = BracketB
_style_list["-["] = BracketB
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2009-12-10 00:09:11
|
Revision: 8016
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8016&view=rev
Author: heeres
Date: 2009-12-10 00:09:03 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
Mplot3d: fix scatter3d markers bug
Modified Paths:
--------------
branches/v0_99_maint/lib/mpl_toolkits/mplot3d/art3d.py
Modified: branches/v0_99_maint/lib/mpl_toolkits/mplot3d/art3d.py
===================================================================
--- branches/v0_99_maint/lib/mpl_toolkits/mplot3d/art3d.py 2009-12-10 00:03:03 UTC (rev 8015)
+++ branches/v0_99_maint/lib/mpl_toolkits/mplot3d/art3d.py 2009-12-10 00:09:03 UTC (rev 8016)
@@ -240,6 +240,7 @@
def __init__(self, *args, **kwargs):
PatchCollection.__init__(self, *args, **kwargs)
+ self._old_draw = lambda x: PatchCollection.draw(self, x)
def set_3d_properties(self, zs, zdir):
xs, ys = zip(*self.get_offsets())
@@ -259,10 +260,15 @@
return min(vzs)
def draw(self, renderer):
- PatchCollection.draw(self, renderer)
+ self._old_draw(renderer)
def patch_collection_2d_to_3d(col, zs=0, zdir='z'):
"""Convert a PatchCollection to a Patch3DCollection object."""
+
+ # The tricky part here is that there are several classes that are
+ # derived from PatchCollection. We need to use the right draw method.
+ col._old_draw = col.draw
+
col.__class__ = Patch3DCollection
col.set_3d_properties(zs, zdir)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2009-12-10 00:03:13
|
Revision: 8015
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8015&view=rev
Author: heeres
Date: 2009-12-10 00:03:03 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
mplot3d updates:
* Fix scatter markers
* Add facecolor support for plot_surface
* Fix XYZ-pane order drawing
* Add examples (animations, colored surface)
Modified Paths:
--------------
trunk/matplotlib/examples/mplot3d/bars3d_demo.py
trunk/matplotlib/examples/mplot3d/hist3d_demo.py
trunk/matplotlib/examples/mplot3d/scatter3d_demo.py
trunk/matplotlib/examples/mplot3d/surface3d_demo.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py
Added Paths:
-----------
trunk/matplotlib/examples/mplot3d/rotate_axes3d_demo.py
trunk/matplotlib/examples/mplot3d/surface3d_demo3.py
trunk/matplotlib/examples/mplot3d/wire3d_animation_demo.py
Modified: trunk/matplotlib/examples/mplot3d/bars3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/bars3d_demo.py 2009-12-09 20:29:10 UTC (rev 8014)
+++ trunk/matplotlib/examples/mplot3d/bars3d_demo.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -7,8 +7,13 @@
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
xs = np.arange(20)
ys = np.random.rand(20)
- ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8)
+ # You can provide either a single color or an array. To demonstrate this,
+ # the first bar of each set will be colored cyan.
+ cs = [c] * len(xs)
+ cs[0] = 'c'
+ ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)
+
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
Modified: trunk/matplotlib/examples/mplot3d/hist3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/hist3d_demo.py 2009-12-09 20:29:10 UTC (rev 8014)
+++ trunk/matplotlib/examples/mplot3d/hist3d_demo.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -16,6 +16,7 @@
dx = 0.5 * np.ones_like(zpos)
dy = dx.copy()
dz = hist.flatten()
+
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b')
plt.show()
Added: trunk/matplotlib/examples/mplot3d/rotate_axes3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/rotate_axes3d_demo.py (rev 0)
+++ trunk/matplotlib/examples/mplot3d/rotate_axes3d_demo.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -0,0 +1,15 @@
+from mpl_toolkits.mplot3d import axes3d
+import matplotlib.pyplot as plt
+import numpy as np
+
+plt.ion()
+
+fig = plt.figure()
+ax = axes3d.Axes3D(fig)
+X, Y, Z = axes3d.get_test_data(0.1)
+ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)
+
+for angle in range(0, 360):
+ ax.view_init(30, angle)
+ plt.draw()
+
Modified: trunk/matplotlib/examples/mplot3d/scatter3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/scatter3d_demo.py 2009-12-09 20:29:10 UTC (rev 8014)
+++ trunk/matplotlib/examples/mplot3d/scatter3d_demo.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -2,18 +2,17 @@
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
-
def randrange(n, vmin, vmax):
return (vmax-vmin)*np.random.rand(n) + vmin
fig = plt.figure()
ax = Axes3D(fig)
n = 100
-for c, zl, zh in [('r', -50, -25), ('b', -30, -5)]:
+for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
xs = randrange(n, 23, 32)
ys = randrange(n, 0, 100)
zs = randrange(n, zl, zh)
- ax.scatter(xs, ys, zs, c=c)
+ ax.scatter(xs, ys, zs, c=c, marker=m)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
Modified: trunk/matplotlib/examples/mplot3d/surface3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/surface3d_demo.py 2009-12-09 20:29:10 UTC (rev 8014)
+++ trunk/matplotlib/examples/mplot3d/surface3d_demo.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -1,5 +1,6 @@
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
+from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
@@ -10,7 +11,14 @@
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
-ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
+surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,
+ linewidth=0, antialiased=False)
+ax.set_zlim3d(-1.01, 1.01)
+ax.w_zaxis.set_major_locator(LinearLocator(10))
+ax.w_zaxis.set_major_formatter(FormatStrFormatter('%.03f'))
+
+fig.colorbar(surf, shrink=0.5, aspect=5)
+
plt.show()
Added: trunk/matplotlib/examples/mplot3d/surface3d_demo3.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/surface3d_demo3.py (rev 0)
+++ trunk/matplotlib/examples/mplot3d/surface3d_demo3.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -0,0 +1,31 @@
+from mpl_toolkits.mplot3d import Axes3D
+from matplotlib import cm
+from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter
+import matplotlib.pyplot as plt
+import numpy as np
+
+fig = plt.figure()
+ax = Axes3D(fig)
+X = np.arange(-5, 5, 0.25)
+xlen = len(X)
+Y = np.arange(-5, 5, 0.25)
+ylen = len(Y)
+X, Y = np.meshgrid(X, Y)
+R = np.sqrt(X**2 + Y**2)
+Z = np.sin(R)
+
+colortuple = ('y', 'b')
+colors = np.empty(X.shape, dtype=str)
+for y in range(ylen):
+ for x in range(xlen):
+ colors[x, y] = colortuple[(x + y) % len(colortuple)]
+
+surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=colors,
+ linewidth=0, antialiased=False)
+
+ax.set_zlim3d(-1.01, 1.01)
+ax.w_zaxis.set_major_locator(LinearLocator(10))
+ax.w_zaxis.set_major_formatter(FormatStrFormatter('%.03f'))
+
+plt.show()
+
Added: trunk/matplotlib/examples/mplot3d/wire3d_animation_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/wire3d_animation_demo.py (rev 0)
+++ trunk/matplotlib/examples/mplot3d/wire3d_animation_demo.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -0,0 +1,34 @@
+from mpl_toolkits.mplot3d import axes3d
+import matplotlib.pyplot as plt
+import numpy as np
+import time
+
+def generate(X, Y, phi):
+ R = 1 - np.sqrt(X**2 + Y**2)
+ return np.cos(2 * np.pi * X + phi) * R
+
+plt.ion()
+fig = plt.figure()
+ax = axes3d.Axes3D(fig)
+
+xs = np.linspace(-1, 1, 50)
+ys = np.linspace(-1, 1, 50)
+X, Y = np.meshgrid(xs, ys)
+Z = generate(X, Y, 0.0)
+
+wframe = None
+tstart = time.time()
+for phi in np.linspace(0, 360 / 2 / np.pi, 100):
+
+ oldcol = wframe
+
+ Z = generate(X, Y, phi)
+ wframe = ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2)
+
+ # Remove old line collection before drawing
+ if oldcol is not None:
+ ax.collections.remove(oldcol)
+
+ plt.draw()
+
+print 'FPS: %f' % (100 / (time.time() - tstart))
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py 2009-12-09 20:29:10 UTC (rev 8014)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -274,6 +274,7 @@
def __init__(self, *args, **kwargs):
PatchCollection.__init__(self, *args, **kwargs)
+ self._old_draw = lambda x: PatchCollection.draw(self, x)
def set_3d_properties(self, zs, zdir):
xs, ys = zip(*self.get_offsets())
@@ -293,10 +294,15 @@
return min(vzs)
def draw(self, renderer):
- PatchCollection.draw(self, renderer)
+ self._old_draw(renderer)
def patch_collection_2d_to_3d(col, zs=0, zdir='z'):
"""Convert a PatchCollection to a Patch3DCollection object."""
+
+ # The tricky part here is that there are several classes that are
+ # derived from PatchCollection. We need to use the right draw method.
+ col._old_draw = col.draw
+
col.__class__ = Patch3DCollection
col.set_3d_properties(zs, zdir)
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-12-09 20:29:10 UTC (rev 8014)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -13,7 +13,7 @@
from matplotlib.transforms import Bbox
from matplotlib import collections
import numpy as np
-from matplotlib.colors import Normalize, colorConverter
+from matplotlib.colors import Normalize, colorConverter, LightSource
import art3d
import proj3d
@@ -37,6 +37,21 @@
"""
def __init__(self, fig, rect=None, *args, **kwargs):
+ '''
+ Build an :class:`Axes3D` instance in
+ :class:`~matplotlib.figure.Figure` *fig* with
+ *rect=[left, bottom, width, height]* in
+ :class:`~matplotlib.figure.Figure` coordinates
+
+ Optional keyword arguments:
+
+ ================ =========================================
+ Keyword Description
+ ================ =========================================
+ *azim* Azimuthal viewing angle (default -60)
+ *elev* Elevation viewing angle (default 30)
+ '''
+
if rect is None:
rect = [0.0, 0.0, 1.0, 1.0]
self.fig = fig
@@ -146,9 +161,12 @@
for i, (z, patch) in enumerate(zlist):
patch.zorder = i
- self.w_xaxis.draw(renderer)
- self.w_yaxis.draw(renderer)
- self.w_zaxis.draw(renderer)
+ axes = (self.w_xaxis, self.w_yaxis, self.w_zaxis)
+ for ax in axes:
+ ax.draw_pane(renderer)
+ for ax in axes:
+ ax.draw(renderer)
+
Axes.draw(self, renderer)
def get_axis_position(self):
@@ -322,8 +340,9 @@
self.grid(rcParams['axes3d.grid'])
def _button_press(self, event):
- self.button_pressed = event.button
- self.sx, self.sy = event.xdata, event.ydata
+ if event.inaxes == self:
+ self.button_pressed = event.button
+ self.sx, self.sy = event.xdata, event.ydata
def _button_release(self, event):
self.button_pressed = None
@@ -565,6 +584,12 @@
*cstride* Array column stride (step size)
*color* Color of the surface patches
*cmap* A colormap for the surface patches.
+ *facecolors* Face colors for the individual patches
+ *norm* An instance of Normalize to map values to colors
+ *vmin* Minimum value to map
+ *vmax* Maximum value to map
+ *shade* Whether to shade the facecolors, default:
+ false when cmap specified, true otherwise
========== ================================================
'''
@@ -575,13 +600,28 @@
rstride = kwargs.pop('rstride', 10)
cstride = kwargs.pop('cstride', 10)
- color = kwargs.pop('color', 'b')
- color = np.array(colorConverter.to_rgba(color))
+ if 'facecolors' in kwargs:
+ fcolors = kwargs.pop('facecolors')
+ else:
+ color = np.array(colorConverter.to_rgba(kwargs.pop('color', 'b')))
+ fcolors = None
+
cmap = kwargs.get('cmap', None)
+ norm = kwargs.pop('norm', None)
+ vmin = kwargs.pop('vmin', None)
+ vmax = kwargs.pop('vmax', None)
+ linewidth = kwargs.get('linewidth', None)
+ shade = kwargs.pop('shade', cmap is None)
+ lightsource = kwargs.pop('lightsource', None)
+ # Shade the data
+ if shade and cmap is not None and fcolors is not None:
+ fcolors = self._shade_colors_lightsource(Z, cmap, lightsource)
+
polys = []
normals = []
- avgz = []
+ #colset contains the data for coloring: either average z or the facecolor
+ colset = []
for rs in np.arange(0, rows-1, rstride):
for cs in np.arange(0, cols-1, cstride):
ps = []
@@ -609,19 +649,38 @@
lastp = p
avgzsum += p[2]
polys.append(ps2)
- avgz.append(avgzsum / len(ps2))
- v1 = np.array(ps2[0]) - np.array(ps2[1])
- v2 = np.array(ps2[2]) - np.array(ps2[0])
- normals.append(np.cross(v1, v2))
+ if fcolors is not None:
+ colset.append(fcolors[rs][cs])
+ else:
+ colset.append(avgzsum / len(ps2))
+ # Only need vectors to shade if no cmap
+ if cmap is None and shade:
+ v1 = np.array(ps2[0]) - np.array(ps2[1])
+ v2 = np.array(ps2[2]) - np.array(ps2[0])
+ normals.append(np.cross(v1, v2))
+
polyc = art3d.Poly3DCollection(polys, *args, **kwargs)
- if cmap is not None:
- polyc.set_array(np.array(avgz))
- polyc.set_linewidth(0)
+
+ if fcolors is not None:
+ if shade:
+ colset = self._shade_colors(colset, normals)
+ polyc.set_facecolors(colset)
+ polyc.set_edgecolors(colset)
+ elif cmap:
+ colset = np.array(colset)
+ polyc.set_array(colset)
+ if vmin is not None or vmax is not None:
+ polyc.set_clim(vmin, vmax)
+ if norm is not None:
+ polyc.set_norm(norm)
else:
- colors = self._shade_colors(color, normals)
- polyc.set_facecolors(colors)
+ if shade:
+ colset = self._shade_colors(color, normals)
+ else:
+ colset = color
+ polyc.set_facecolors(colset)
self.add_collection(polyc)
self.auto_scale_xyz(X, Y, Z, had_data)
@@ -643,24 +702,39 @@
return normals
def _shade_colors(self, color, normals):
+ '''
+ Shade *color* using normal vectors given by *normals*.
+ *color* can also be an array of the same length as *normals*.
+ '''
+
shade = []
for n in normals:
- n = n / proj3d.mod(n) * 5
+ n = n / proj3d.mod(n)
shade.append(np.dot(n, [-1, -1, 0.5]))
shade = np.array(shade)
mask = ~np.isnan(shade)
if len(shade[mask]) > 0:
- norm = Normalize(min(shade[mask]), max(shade[mask]))
- color = color.copy()
- color[3] = 1
- colors = [color * (0.5 + norm(v) * 0.5) for v in shade]
+ norm = Normalize(min(shade[mask]), max(shade[mask]))
+ if art3d.iscolor(color):
+ color = color.copy()
+ color[3] = 1
+ colors = [color * (0.5 + norm(v) * 0.5) for v in shade]
+ else:
+ colors = [np.array(colorConverter.to_rgba(c)) * \
+ (0.5 + norm(v) * 0.5) \
+ for c, v in zip(color, shade)]
else:
- colors = color.copy()
+ colors = color.copy()
return colors
+ def _shade_colors_lightsource(self, data, cmap, lightsource):
+ if lightsource is None:
+ lightsource = LightSource(azdeg=135, altdeg=55)
+ return lightsource.shade(data, cmap)
+
def plot_wireframe(self, X, Y, Z, *args, **kwargs):
'''
Plot a 3D wireframe.
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py 2009-12-09 20:29:10 UTC (rev 8014)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py 2009-12-10 00:03:03 UTC (rev 8015)
@@ -75,7 +75,7 @@
maxis.XAxis.__init__(self, axes, *args, **kwargs)
self.line = mlines.Line2D(xdata=(0, 0), ydata=(0, 0),
linewidth=0.75,
- color=(0,0, 0,0),
+ color=(0, 0, 0, 1),
antialiased=True,
)
@@ -100,8 +100,8 @@
majorLabels = [self.major.formatter(val, i) for i, val in enumerate(majorLocs)]
return majorLabels, majorLocs
- def get_major_ticks(self):
- ticks = maxis.XAxis.get_major_ticks(self)
+ def get_major_ticks(self, numticks=None):
+ ticks = maxis.XAxis.get_major_ticks(self, numticks)
for t in ticks:
t.tick1line.set_transform(self.axes.transData)
t.tick2line.set_transform(self.axes.transData)
@@ -132,23 +132,7 @@
else:
return len(text) > 4
- def draw(self, renderer):
- self.label._transform = self.axes.transData
- renderer.open_group('axis3d')
-
- # code from XAxis
- majorTicks = self.get_major_ticks()
- majorLocs = self.major.locator()
-
- # filter locations here so that no extra grid lines are drawn
- interval = self.get_view_interval()
- majorLocs = [loc for loc in majorLocs if \
- interval[0] < loc < interval[1]]
- self.major.formatter.set_locs(majorLocs)
- majorLabels = [self.major.formatter(val, i)
- for i, val in enumerate(majorLocs)]
-
- # Determine bounds
+ def _get_coord_info(self, renderer):
minx, maxx, miny, maxy, minz, maxz = self.axes.get_w_lims()
mins = np.array((minx, miny, minz))
maxs = np.array((maxx, maxy, maxz))
@@ -157,15 +141,19 @@
mins = mins - deltas / 4.
maxs = maxs + deltas / 4.
- # Determine which planes should be visible by the avg z value
vals = mins[0], maxs[0], mins[1], maxs[1], mins[2], maxs[2]
tc = self.axes.tunit_cube(vals, renderer.M)
- #raise RuntimeError('WTF: p1=%s'%p1)
avgz = [tc[p1][2] + tc[p2][2] + tc[p3][2] + tc[p4][2] for \
p1, p2, p3, p4 in self._PLANES]
highs = np.array([avgz[2*i] < avgz[2*i+1] for i in range(3)])
- # Draw plane
+ return mins, maxs, centers, deltas, tc, highs
+
+ def draw_pane(self, renderer):
+ renderer.open_group('pane3d')
+
+ mins, maxs, centers, deltas, tc, highs = self._get_coord_info(renderer)
+
info = self._AXINFO[self.adir]
index = info['i']
if not highs[index]:
@@ -176,6 +164,29 @@
self.set_pane(xys, info['color'])
self.pane.draw(renderer)
+ renderer.close_group('pane3d')
+
+ def draw(self, renderer):
+ self.label._transform = self.axes.transData
+ renderer.open_group('axis3d')
+
+ # code from XAxis
+ majorTicks = self.get_major_ticks()
+ majorLocs = self.major.locator()
+
+ info = self._AXINFO[self.adir]
+ index = info['i']
+
+ # filter locations here so that no extra grid lines are drawn
+ interval = self.get_view_interval()
+ majorLocs = [loc for loc in majorLocs if \
+ interval[0] < loc < interval[1]]
+ self.major.formatter.set_locs(majorLocs)
+ majorLabels = [self.major.formatter(val, i)
+ for i, val in enumerate(majorLocs)]
+
+ mins, maxs, centers, deltas, tc, highs = self._get_coord_info(renderer)
+
# Determine grid lines
minmax = np.where(highs, maxs, mins)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-12-09 20:29:17
|
Revision: 8014
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8014&view=rev
Author: leejjoon
Date: 2009-12-09 20:29:10 +0000 (Wed, 09 Dec 2009)
Log Message:
-----------
print out more meaningful messages when legend is called with artists that are not supported
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/legend.py
trunk/matplotlib/lib/matplotlib/offsetbox.py
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2009-12-08 02:12:38 UTC (rev 8013)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2009-12-09 20:29:10 UTC (rev 8014)
@@ -432,14 +432,6 @@
)
labelboxes = []
-
- for l in labels:
- textbox = TextArea(l, textprops=label_prop,
- multilinebaseline=True, minimumdescent=True)
- text_list.append(textbox._text)
-
- labelboxes.append(textbox)
-
handleboxes = []
@@ -457,7 +449,8 @@
# default trasnform (eg, Collections), you need to
# manually set their transform to the self.get_transform().
- for handle in handles:
+
+ for handle, lab in zip(handles, labels):
if isinstance(handle, RegularPolyCollection) or \
isinstance(handle, CircleCollection):
npoints = self.scatterpoints
@@ -578,32 +571,47 @@
p.set_clip_path(None)
handle_list.append(p)
else:
+ handle_type = type(handle)
+ warnings.warn("Legend does not support %s\nUse proxy artist instead.\n\nhttp://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist\n" % (str(handle_type),))
handle_list.append(None)
- handlebox = DrawingArea(width=self.handlelength*fontsize,
- height=height,
- xdescent=0., ydescent=descent)
+
handle = handle_list[-1]
- handlebox.add_artist(handle)
- if hasattr(handle, "_legmarker"):
- handlebox.add_artist(handle._legmarker)
- handleboxes.append(handlebox)
+ if handle is not None: # handle is None is the artist is not supproted
+ textbox = TextArea(lab, textprops=label_prop,
+ multilinebaseline=True, minimumdescent=True)
+ text_list.append(textbox._text)
+
+ labelboxes.append(textbox)
+ handlebox = DrawingArea(width=self.handlelength*fontsize,
+ height=height,
+ xdescent=0., ydescent=descent)
- # We calculate number of lows in each column. The first
- # (num_largecol) columns will have (nrows+1) rows, and remaing
- # (num_smallcol) columns will have (nrows) rows.
- ncol = min(self._ncol, len(handleboxes))
- nrows, num_largecol = divmod(len(handleboxes), ncol)
- num_smallcol = ncol-num_largecol
+ handlebox.add_artist(handle)
+ if hasattr(handle, "_legmarker"):
+ handlebox.add_artist(handle._legmarker)
+ handleboxes.append(handlebox)
- # starting index of each column and number of rows in it.
- largecol = safezip(range(0, num_largecol*(nrows+1), (nrows+1)),
- [nrows+1] * num_largecol)
- smallcol = safezip(range(num_largecol*(nrows+1), len(handleboxes), nrows),
- [nrows] * num_smallcol)
+ if len(handleboxes) > 0:
+
+ # We calculate number of lows in each column. The first
+ # (num_largecol) columns will have (nrows+1) rows, and remaing
+ # (num_smallcol) columns will have (nrows) rows.
+ ncol = min(self._ncol, len(handleboxes))
+ nrows, num_largecol = divmod(len(handleboxes), ncol)
+ num_smallcol = ncol-num_largecol
+
+ # starting index of each column and number of rows in it.
+ largecol = safezip(range(0, num_largecol*(nrows+1), (nrows+1)),
+ [nrows+1] * num_largecol)
+ smallcol = safezip(range(num_largecol*(nrows+1), len(handleboxes), nrows),
+ [nrows] * num_smallcol)
+ else:
+ largecol, smallcol = [], []
+
handle_label = safezip(handleboxes, labelboxes)
columnbox = []
for i0, di in largecol+smallcol:
Modified: trunk/matplotlib/lib/matplotlib/offsetbox.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/offsetbox.py 2009-12-08 02:12:38 UTC (rev 8013)
+++ trunk/matplotlib/lib/matplotlib/offsetbox.py 2009-12-09 20:29:10 UTC (rev 8014)
@@ -375,6 +375,9 @@
whd_list = [c.get_extent(renderer) for c in self.get_visible_children()]
+ if not whd_list:
+ return 2*pad, 2*pad, pad, pad, []
+
if self.height is None:
height_descent = max([h-yd for w,h,xd,yd in whd_list])
ydescent = max([yd for w,h,xd,yd in whd_list])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-12-08 02:12:46
|
Revision: 8013
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8013&view=rev
Author: efiring
Date: 2009-12-08 02:12:38 +0000 (Tue, 08 Dec 2009)
Log Message:
-----------
bugfix: skip trying to make geos polygon lists if no coast polygons are found
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-08 02:02:49 UTC (rev 8012)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-08 02:12:38 UTC (rev 8013)
@@ -805,7 +805,7 @@
# currently only used in is_land method.
self.landpolygons=[]
self.lakepolygons=[]
- if resolution is not None:
+ if resolution is not None and len(self.coastpolygons) > 0:
#self.islandinlakepolygons=[]
#self.lakeinislandinlakepolygons=[]
x, y = zip(*self.coastpolygons)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-12-08 02:02:59
|
Revision: 8012
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8012&view=rev
Author: efiring
Date: 2009-12-08 02:02:49 +0000 (Tue, 08 Dec 2009)
Log Message:
-----------
Remove spurious whitespace
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/solar.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-07 01:17:27 UTC (rev 8011)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-08 02:02:49 UTC (rev 8012)
@@ -1,7 +1,7 @@
"""
Module for plotting data on maps with matplotlib.
-Contains the :class:`Basemap` class (which does most of the
+Contains the :class:`Basemap` class (which does most of the
heavy lifting), and the following functions:
:func:`NetCDFFile`: Read local and remote NetCDF datasets.
@@ -26,8 +26,8 @@
_mpl_required_version = '0.98'
if _matplotlib_version < _mpl_required_version:
msg = dedent("""
- your matplotlib is too old - basemap requires version %s or
- higher, you have version %s""" %
+ your matplotlib is too old - basemap requires version %s or
+ higher, you have version %s""" %
(_mpl_required_version,_matplotlib_version))
raise ImportError(msg)
from matplotlib import rcParams, is_interactive, _pylab_helpers
@@ -180,12 +180,12 @@
lat_0 center of desired map domain (in degrees).
============== ====================================================
- For ``sinu``, ``moll``, ``npstere``, ``spstere``, ``nplaea``, ``splaea``,
+ For ``sinu``, ``moll``, ``npstere``, ``spstere``, ``nplaea``, ``splaea``,
``npaeqd``, ``spaeqd``, ``robin`` or ``mbtfpq``, the values of
llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, width and height are ignored
(because either they are computed internally, or entire globe is
- always plotted).
-
+ always plotted).
+
For the cylindrical projections (``cyl``, ``merc``, ``mill`` and ``gall``),
the default is to use
llcrnrlon=-180,llcrnrlat=-90, urcrnrlon=180 and urcrnrlat=90). For all other
@@ -193,7 +193,7 @@
corners or width and height must be specified by the user.
For ``ortho`` and ``geos``, the lat/lon values of the corners may be specified,
- or the x/y values of the corners (llcrnrx,llcrnry,urcrnrx,urcrnry) in the
+ or the x/y values of the corners (llcrnrx,llcrnry,urcrnrx,urcrnry) in the
coordinate system of the global projection (with x=0,y=0 at the center
of the global projection). If the corners are not specified,
the entire globe is plotted.
@@ -206,7 +206,7 @@
Keyword Description
============== ====================================================
resolution resolution of boundary database to use. Can be ``c``
- (crude), ``l`` (low), ``i`` (intermediate), ``h``
+ (crude), ``l`` (low), ``i`` (intermediate), ``h``
(high), ``f`` (full) or None.
If None, no boundary data will be read in (and
class methods such as drawcoastlines will raise an
@@ -217,40 +217,40 @@
(http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html).
State, country and river datasets from the Generic
Mapping Tools (http://gmt.soest.hawaii.edu).
- area_thresh coastline or lake with an area smaller than
- area_thresh in km^2 will not be plotted.
+ area_thresh coastline or lake with an area smaller than
+ area_thresh in km^2 will not be plotted.
Default 10000,1000,100,10,1 for resolution
``c``, ``l``, ``i``, ``h``, ``f``.
rsphere radius of the sphere used to define map projection
(default 6370997 meters, close to the arithmetic mean
- radius of the earth). If given as a sequence, the
+ radius of the earth). If given as a sequence, the
first two elements are interpreted as the radii
- of the major and minor axes of an ellipsoid.
- Note: sometimes an ellipsoid is specified by the
+ of the major and minor axes of an ellipsoid.
+ Note: sometimes an ellipsoid is specified by the
major axis and an inverse flattening parameter (if).
The minor axis (b) can be computed from the major
- axis (a) and the inverse flattening parameter using
+ axis (a) and the inverse flattening parameter using
the formula if = a/(a-b).
suppress_ticks suppress automatic drawing of axis ticks and labels
- in map projection coordinates. Default False,
+ in map projection coordinates. Default False,
so parallels and meridians can be labelled instead.
If parallel or meridian labelling is requested
(using drawparallels and drawmeridians methods),
automatic tick labelling will be supressed even if
suppress_ticks=False. suppress_ticks=False
is useful if you want to use your own custom tick
- formatter, or if you want to let matplotlib label
+ formatter, or if you want to let matplotlib label
the axes in meters using map projection
coordinates.
fix_aspect fix aspect ratio of plot to match aspect ratio
of map projection region (default True).
anchor determines how map is placed in axes rectangle
- (passed to axes.set_aspect). Default is ``C``,
+ (passed to axes.set_aspect). Default is ``C``,
which means map is centered.
- Allowed values are
- ``C``, ``SW``, ``S``, ``SE``, ``E``, ``NE``,
+ Allowed values are
+ ``C``, ``SW``, ``S``, ``SE``, ``E``, ``NE``,
``N``, ``NW``, and ``W``.
- ax set default axes instance
+ ax set default axes instance
(default None - matplotlib.pyplot.gca() may be used
to get the current axes instance).
If you don``t want matplotlib.pyplot to be imported,
@@ -258,10 +258,10 @@
instance, or use the ``ax`` keyword in each Basemap
method call that does drawing. In the first case,
all Basemap method calls will draw to the same axes
- instance. In the second case, you can draw to
+ instance. In the second case, you can draw to
different axes with the same Basemap instance.
You can also use the ``ax`` keyword in individual
- method calls to selectively override the default
+ method calls to selectively override the default
axes instance.
============== ====================================================
@@ -279,36 +279,36 @@
and mercator projections.
default is lat_0 for stereographic projection.
default is 0 for mercator projection.
- lat_1 first standard parallel for lambert conformal,
+ lat_1 first standard parallel for lambert conformal,
albers equal area and equidistant conic.
- Latitude of one of the two points on the projection
- centerline for oblique mercator. If lat_1 is not given, but
- lat_0 is, lat_1 is set to lat_0 for lambert
+ Latitude of one of the two points on the projection
+ centerline for oblique mercator. If lat_1 is not given, but
+ lat_0 is, lat_1 is set to lat_0 for lambert
conformal, albers equal area and equidistant conic.
- lat_2 second standard parallel for lambert conformal,
+ lat_2 second standard parallel for lambert conformal,
albers equal area and equidistant conic.
Latitude of one of the two points on the projection
- centerline for oblique mercator. If lat_2 is not
- given it is set to lat_1 for lambert conformal,
+ centerline for oblique mercator. If lat_2 is not
+ given it is set to lat_1 for lambert conformal,
albers equal area and equidistant conic.
lon_1 Longitude of one of the two points on the projection
centerline for oblique mercator.
lon_2 Longitude of one of the two points on the projection
centerline for oblique mercator.
no_rot only used by oblique mercator.
- If set to True, the map projection coordinates will
+ If set to True, the map projection coordinates will
not be rotated to true North. Default is False
(projection coordinates are automatically rotated).
- lat_0 central latitude (y-axis origin) - used by all
- projections.
+ lat_0 central latitude (y-axis origin) - used by all
+ projections.
lon_0 central meridian (x-axis origin) - used by all
projections.
boundinglat bounding latitude for pole-centered projections
- (npstere,spstere,nplaea,splaea,npaeqd,spaeqd).
+ (npstere,spstere,nplaea,splaea,npaeqd,spaeqd).
These projections are square regions centered
on the north or south pole.
The longitude lon_0 is at 6-o'clock, and the
- latitude circle boundinglat is tangent to the edge
+ latitude circle boundinglat is tangent to the edge
of the map at lon_0.
satellite_height height of satellite (in m) above equator -
only relevant for geostationary projections
@@ -325,11 +325,11 @@
projection map projection. Print the module variable
``supported_projections`` to see a list of allowed
values.
- aspect map aspect ratio
+ aspect map aspect ratio
(size of y dimension / size of x dimension).
llcrnrlon longitude of lower left hand corner of the
selected map domain.
- llcrnrlat latitude of lower left hand corner of the
+ llcrnrlat latitude of lower left hand corner of the
selected map domain.
urcrnrlon longitude of upper right hand corner of the
selected map domain.
@@ -337,7 +337,7 @@
selected map domain.
llcrnrx x value of lower left hand corner of the
selected map domain in map projection coordinates.
- llcrnry y value of lower left hand corner of the
+ llcrnry y value of lower left hand corner of the
selected map domain in map projection coordinates.
urcrnrx x value of upper right hand corner of the
selected map domain in map projection coordinates.
@@ -345,8 +345,8 @@
selected map domain in map projection coordinates.
rmajor equatorial radius of ellipsoid used (in meters).
rminor polar radius of ellipsoid used (in meters).
- resolution resolution of boundary dataset being used (``c``
- for crude, ``l`` for low, etc.).
+ resolution resolution of boundary dataset being used (``c``
+ for crude, ``l`` for low, etc.).
If None, no boundary dataset is associated with the
Basemap instance.
proj4string the string describing the map projection that is
@@ -372,7 +372,7 @@
self.llcrnrlon and self.llcrnrlat.
Input arguments lon, lat can be either scalar floats, sequences
- or numpy arrays.
+ or numpy arrays.
**Example Usage:**
@@ -650,7 +650,7 @@
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
elif projection in _cylproj:
if projection == 'merc':
- if lat_ts is None:
+ if lat_ts is None:
lat_ts = 0.
projparams['lat_ts']=lat_ts
if not using_corners:
@@ -795,7 +795,7 @@
ind.append(len(xd))
for i in ind:
# don't add empty lists.
- if len(range(iprev,i)):
+ if len(range(iprev,i)):
coastsegs.append(zip(x[iprev:i],y[iprev:i]))
iprev = i
else:
@@ -887,7 +887,7 @@
raise ValueError('%s projection cannot cross pole'%(self.projection))
# make sure orthographic or gnomonic projection has containsPole=True
# we will compute the intersections in stereographic
- # coordinates, then transform to orthographic. This is
+ # coordinates, then transform to orthographic. This is
# because these projections are only defined on a hemisphere, and
# some boundary features (like Eurasia) would be undefined otherwise.
if self.projection in ['ortho','gnom'] and name == 'gshhs':
@@ -895,7 +895,7 @@
lon_0=self.projparams['lon_0']
lat_0=self.projparams['lat_0']
re = self.projparams['R']
- # center of stereographic projection restricted to be
+ # center of stereographic projection restricted to be
# nearest one of 6 points on the sphere (every 90 deg lat/lon).
lon0 = 90.*(np.around(lon_0/90.))
lat0 = 90.*(np.around(lat_0/90.))
@@ -958,7 +958,7 @@
else:
poly = Shape(b)
# this is a workaround to avoid
- # "GEOS_ERROR: TopologyException:
+ # "GEOS_ERROR: TopologyException:
# found non-noded intersection between ..."
# with geos 3.0.0
if _geoslib.__geos_major_version__ > 2:
@@ -1035,7 +1035,7 @@
# create a GEOS geometry object.
poly = Shape(b)
# this is a workaround to avoid
- # "GEOS_ERROR: TopologyException:
+ # "GEOS_ERROR: TopologyException:
# found non-noded intersection between ..."
# with geos 3.0.0
if _geoslib.__geos_major_version__ > 2:
@@ -1212,7 +1212,7 @@
linewidth line width for boundary (default 1.)
color color of boundary line (default black)
fill_color fill the map region background with this
- color (default is no fill or fill with axis
+ color (default is no fill or fill with axis
background color).
zorder sets the zorder for filling map background
(default 0).
@@ -1411,7 +1411,7 @@
antialiased antialiasing switch for coastlines (default True).
ax axes instance (overrides default axes instance)
zorder sets the zorder for the coastlines (if not specified,
- uses default zorder for
+ uses default zorder for
matplotlib.patches.LineCollections).
============== ====================================================
@@ -1443,11 +1443,11 @@
============== ====================================================
linewidth country boundary line width (default 0.5)
color country boundary line color (default black)
- antialiased antialiasing switch for country boundaries (default
+ antialiased antialiasing switch for country boundaries (default
True).
ax axes instance (overrides default axes instance)
zorder sets the zorder for the country boundaries (if not
- specified uses default zorder for
+ specified uses default zorder for
matplotlib.patches.LineCollections).
============== ====================================================
@@ -1486,7 +1486,7 @@
antialiased antialiasing switch for state boundaries
(default True).
ax axes instance (overrides default axes instance)
- zorder sets the zorder for the state boundaries (if not
+ zorder sets the zorder for the state boundaries (if not
specified, uses default zorder for
matplotlib.patches.LineCollections).
============== ====================================================
@@ -1523,10 +1523,10 @@
============== ====================================================
linewidth river boundary line width (default 0.5)
color river boundary line color (default black)
- antialiased antialiasing switch for river boundaries (default
+ antialiased antialiasing switch for river boundaries (default
True).
ax axes instance (overrides default axes instance)
- zorder sets the zorder for the rivers (if not
+ zorder sets the zorder for the rivers (if not
specified uses default zorder for
matplotlib.patches.LineCollections).
============== ====================================================
@@ -1588,25 +1588,25 @@
Argument Description
============== ====================================================
shapefile path to shapefile components. Example:
- shapefile='/home/jeff/esri/world_borders' assumes
- that world_borders.shp, world_borders.shx and
+ shapefile='/home/jeff/esri/world_borders' assumes
+ that world_borders.shp, world_borders.shx and
world_borders.dbf live in /home/jeff/esri.
name name for Basemap attribute to hold the shapefile
- vertices or points in map projection
- coordinates. Class attribute name+'_info' is a list
- of dictionaries, one for each shape, containing
+ vertices or points in map projection
+ coordinates. Class attribute name+'_info' is a list
+ of dictionaries, one for each shape, containing
attributes of each shape from dbf file, For
example, if name='counties', self.counties
- will be a list of x,y vertices for each shape in
+ will be a list of x,y vertices for each shape in
map projection coordinates and self.counties_info
will be a list of dictionaries with shape
- attributes. Rings in individual Polygon
+ attributes. Rings in individual Polygon
shapes are split out into separate polygons, and
additional keys 'RINGNUM' and 'SHAPENUM' are added
to the shape attribute dictionary.
============== ====================================================
- The following optional keyword arguments are only relevant for Polyline
+ The following optional keyword arguments are only relevant for Polyline
and Polygon shape types, for Point and MultiPoint shapes they are
ignored.
@@ -1615,13 +1615,13 @@
============== ====================================================
Keyword Description
============== ====================================================
- drawbounds draw boundaries of shapes (default True).
- zorder shape boundary zorder (if not specified,
- default for mathplotlib.lines.LineCollection
+ drawbounds draw boundaries of shapes (default True).
+ zorder shape boundary zorder (if not specified,
+ default for mathplotlib.lines.LineCollection
is used).
linewidth shape boundary line width (default 0.5)
color shape boundary line color (default black)
- antialiased antialiasing switch for shape boundaries
+ antialiased antialiasing switch for shape boundaries
(default True).
ax axes instance (overrides default axes instance)
============== ====================================================
@@ -1632,7 +1632,7 @@
the SHPT* constants defined in the shapelib module, see
http://shapelib.maptools.org/shp_api.html) and min and
max are 4-element lists with the minimum and maximum values of the
- vertices. If ``drawbounds=True`` a
+ vertices. If ``drawbounds=True`` a
matplotlib.patches.LineCollection object is appended to the tuple.
"""
if not os.path.exists('%s.shp'%shapefile):
@@ -1723,7 +1723,7 @@
fmt='%g',xoffset=None,yoffset=None,ax=None,latmax=None,
**kwargs):
"""
- Draw and label parallels (latitude lines) for values (in degrees)
+ Draw and label parallels (latitude lines) for values (in degrees)
given in the sequence ``circles``.
.. tabularcolumns:: |l|L|
@@ -1749,7 +1749,7 @@
labelled with "N" and "S".
fmt a format string to format the parallel labels
(default '%g') **or** a function that takes a
- latitude value in degrees as it's only argument
+ latitude value in degrees as it's only argument
and returns a formatted string.
xoffset label offset from edge of map in x-direction
(default is 0.01 times width of map in map
@@ -1761,13 +1761,13 @@
latmax absolute value of latitude to which meridians are drawn
(default is 80).
\**kwargs additional keyword arguments controlling text
- for labels that are passed on to
+ for labels that are passed on to
the text method of the axes instance (see
matplotlib.pyplot.text documentation).
============== ====================================================
returns a dictionary whose keys are the parallel values, and
- whose values are tuples containing lists of the
+ whose values are tuples containing lists of the
matplotlib.lines.Line2D and matplotlib.text.Text instances
associated with each parallel.
"""
@@ -1811,7 +1811,7 @@
x,y = self(lons,lats)
# remove points outside domain.
# leave a little slop around edges (3*xdelta)
- # don't really know why, but this appears to be needed to
+ # don't really know why, but this appears to be needed to
# or lines sometimes don't reach edge of plot.
testx = np.logical_and(x>=self.xmin-3*xdelta,x<=self.xmax+3*xdelta)
x = np.compress(testx, x)
@@ -2001,7 +2001,7 @@
labelled with "E" and "W".
fmt a format string to format the meridian labels
(default '%g') **or** a function that takes a
- longitude value in degrees as it's only argument
+ longitude value in degrees as it's only argument
and returns a formatted string.
xoffset label offset from edge of map in x-direction
(default is 0.01 times width of map in map
@@ -2013,13 +2013,13 @@
latmax absolute value of latitude to which meridians are drawn
(default is 80).
\**kwargs additional keyword arguments controlling text
- for labels that are passed on to
+ for labels that are passed on to
the text method of the axes instance (see
matplotlib.pyplot.text documentation).
============== ====================================================
returns a dictionary whose keys are the meridian values, and
- whose values are tuples containing lists of the
+ whose values are tuples containing lists of the
matplotlib.lines.Line2D and matplotlib.text.Text instances
associated with each meridian.
"""
@@ -2049,7 +2049,7 @@
x,y = self(lons,lats)
# remove points outside domain.
# leave a little slop around edges (3*xdelta)
- # don't really know why, but this appears to be needed to
+ # don't really know why, but this appears to be needed to
# or lines sometimes don't reach edge of plot.
testx = np.logical_and(x>=self.xmin-3*xdelta,x<=self.xmax+3*xdelta)
x = np.compress(testx, x)
@@ -2218,7 +2218,7 @@
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.
+ 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
@@ -2308,7 +2308,7 @@
Interpolate a scalar field (``datin``) from a lat/lon grid with
longitudes = ``lons`` and latitudes = ``lats`` to a ``ny`` by ``nx``
map projection grid. Typically used to transform data to
- map projection coordinates for plotting on a map with
+ map projection coordinates for plotting on a map with
the :meth:`imshow`.
.. tabularcolumns:: |l|L|
@@ -2320,7 +2320,7 @@
lons, lats rank-1 arrays containing longitudes and latitudes
(in degrees) of input data in increasing order.
For non-cylindrical projections (those other than
- ``cyl``, ``merc``, ``gall`` and ``mill``) lons must
+ ``cyl``, ``merc``, ``gall`` and ``mill``) lons must
fit within range -180 to 180.
nx, ny The size of the output regular grid in map
projection coordinates
@@ -2391,12 +2391,12 @@
lons, lats rank-1 arrays containing longitudes and latitudes
(in degrees) of input data in increasing order.
For non-cylindrical projections (those other than
- ``cyl``, ``merc``, ``gall`` and ``mill``) lons must
+ ``cyl``, ``merc``, ``gall`` and ``mill``) lons must
fit within range -180 to 180.
nx, ny The size of the output regular grid in map
projection coordinates
============== ====================================================
-
+
.. tabularcolumns:: |l|L|
============== ====================================================
@@ -2442,7 +2442,7 @@
def rotate_vector(self,uin,vin,lons,lats,returnxy=False):
"""
Rotate a vector field (``uin,vin``) on a rectilinear grid
- with longitudes = ``lons`` and latitudes = ``lats`` from
+ with longitudes = ``lons`` and latitudes = ``lats`` from
geographical (lat/lon) into map projection (x/y) coordinates.
Differs from transform_vector in that no interpolation is done.
@@ -2463,13 +2463,13 @@
lons, lats Arrays containing longitudes and latitudes
(in degrees) of input data in increasing order.
For non-cylindrical projections (those other than
- ``cyl``, ``merc``, ``gall`` and ``mill``) lons must
+ ``cyl``, ``merc``, ``gall`` and ``mill``) lons must
fit within range -180 to 180.
============== ====================================================
Returns ``uout, vout`` (rotated vector field).
- If the optional keyword argument
- ``returnxy`` is True (default is False),
+ If the optional keyword argument
+ ``returnxy`` is True (default is False),
returns ``uout,vout,x,y`` (where ``x,y`` are the map projection
coordinates of the grid defined by ``lons,lats``).
"""
@@ -2480,7 +2480,7 @@
if lons.ndim == lats.ndim == 1 and uin.ndim == vin.ndim == 2 and\
uin.shape[1] == vin.shape[1] == lons.shape[0] and\
uin.shape[0] == vin.shape[0] == lats.shape[0]:
- lons, lats = np.meshgrid(lons, lats)
+ lons, lats = np.meshgrid(lons, lats)
else:
if not lons.shape == lats.shape == uin.shape == vin.shape:
raise TypeError("shapes of lons,lats and uin,vin don't match")
@@ -2493,41 +2493,41 @@
vin = vin.filled(1)
else:
masked = False
-
+
# Map the (lon, lat) vector in the complex plane.
uvc = uin + 1j*vin
uvmag = np.abs(uvc)
theta = np.angle(uvc)
-
- # Define a displacement (dlon, dlat) that moves all
- # positions (lons, lats) a small distance in the
- # direction of the original vector.
+
+ # Define a displacement (dlon, dlat) that moves all
+ # positions (lons, lats) a small distance in the
+ # direction of the original vector.
dc = 1E-5 * np.exp(theta*1j)
dlat = dc.imag * np.cos(np.radians(lats))
- dlon = dc.real
-
+ dlon = dc.real
+
# Deal with displacements that overshoot the North or South Pole.
farnorth = np.abs(lats+dlat) >= 90.0
somenorth = farnorth.any()
if somenorth:
dlon[farnorth] *= -1.0
dlat[farnorth] *= -1.0
-
+
# Add displacement to original location and find the native coordinates.
lon1 = lons + dlon
lat1 = lats + dlat
xn, yn = self(lon1, lat1)
-
- # Determine the angle of the displacement in the native coordinates.
+
+ # Determine the angle of the displacement in the native coordinates.
vecangle = np.arctan2(yn-y, xn-x)
if somenorth:
vecangle[farnorth] += np.pi
-
+
# Compute the x-y components of the original vector.
uvcout = uvmag * np.exp(1j*vecangle)
uout = uvcout.real
vout = uvcout.imag
-
+
if masked:
uout = ma.array(uout, mask=mask)
vout = ma.array(vout, mask=mask)
@@ -2581,7 +2581,7 @@
"""
ax = kwargs.pop('ax', None) or self._check_ax()
# if ax kwarg not supplied, and ax attribute not set, import pyplot.
- if self.ax is None and kwargs.pop('ax', None) is None:
+ if self.ax is None and kwargs.pop('ax', None) is None:
import matplotlib.pyplot as plt
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
@@ -2612,7 +2612,7 @@
def plot(self, *args, **kwargs):
"""
- Draw lines and/or markers on the map
+ Draw lines and/or markers on the map
(see matplotlib.pyplot.plot documentation).
Extra keyword ``ax`` can be used to override the default axis instance.
@@ -2641,7 +2641,7 @@
def imshow(self, *args, **kwargs):
"""
- Display an image over the map
+ Display an image over the map
(see matplotlib.pyplot.imshow documentation).
``extent`` and ``origin`` keywords set automatically so image
@@ -2655,7 +2655,7 @@
"""
ax = kwargs.pop('ax', None) or self._check_ax()
# if ax kwarg not supplied, and ax attribute not set, import pyplot.
- if self.ax is None and kwargs.pop('ax', None) is None:
+ if self.ax is None and kwargs.pop('ax', None) is None:
import matplotlib.pyplot as plt
kwargs['extent']=(self.llcrnrx,self.urcrnrx,self.llcrnry,self.urcrnry)
# use origin='lower', unless overridden.
@@ -2703,7 +2703,7 @@
"""
ax = kwargs.pop('ax', None) or self._check_ax()
# if ax kwarg not supplied, and ax attribute not set, import pyplot.
- if self.ax is None and kwargs.pop('ax', None) is None:
+ if self.ax is None and kwargs.pop('ax', None) is None:
import matplotlib.pyplot as plt
# make x,y masked arrays
# (masked where data is outside of projection limb)
@@ -2747,7 +2747,7 @@
"""
ax = kwargs.pop('ax', None) or self._check_ax()
# if ax kwarg not supplied, and ax attribute not set, import pyplot.
- if self.ax is None and kwargs.pop('ax', None) is None:
+ if self.ax is None and kwargs.pop('ax', None) is None:
import matplotlib.pyplot as plt
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
@@ -2778,7 +2778,7 @@
def contour(self,x,y,data,*args,**kwargs):
"""
- Make a contour plot over the map
+ Make a contour plot over the map
(see matplotlib.pyplot.contour documentation).
Extra keyword ``ax`` can be used to override the default axis instance.
@@ -2787,7 +2787,7 @@
"""
ax = kwargs.pop('ax', None) or self._check_ax()
# if ax kwarg not supplied, and ax attribute not set, import pyplot.
- if self.ax is None and kwargs.pop('ax', None) is None:
+ if self.ax is None and kwargs.pop('ax', None) is None:
import matplotlib.pyplot as plt
# make sure x is monotonically increasing - if not,
# print warning suggesting that the data be shifted in longitude
@@ -2862,7 +2862,7 @@
"""
ax = kwargs.pop('ax', None) or self._check_ax()
# if ax kwarg not supplied, and ax attribute not set, import pyplot.
- if self.ax is None and kwargs.pop('ax', None) is None:
+ if self.ax is None and kwargs.pop('ax', None) is None:
import matplotlib.pyplot as plt
# make sure x is monotonically increasing - if not,
# print warning suggesting that the data be shifted in longitude
@@ -2942,7 +2942,7 @@
"""
ax = kwargs.pop('ax', None) or self._check_ax()
# if ax kwarg not supplied, and ax attribute not set, import pyplot.
- if self.ax is None and kwargs.pop('ax', None) is None:
+ if self.ax is None and kwargs.pop('ax', None) is None:
import matplotlib.pyplot as plt
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
@@ -2972,8 +2972,8 @@
Other \*args and \**kwargs passed on to matplotlib.pyplot.barbs
- Returns two matplotlib.axes.Barbs instances, one for the Northern
- Hemisphere and one for the Southern Hemisphere.
+ Returns two matplotlib.axes.Barbs instances, one for the Northern
+ Hemisphere and one for the Southern Hemisphere.
"""
if _matplotlib_version < '0.98.3':
msg = dedent("""
@@ -2982,7 +2982,7 @@
raise NotImplementedError(msg)
ax = kwargs.pop('ax', None) or self._check_ax()
# if ax kwarg not supplied, and ax attribute not set, import pyplot.
- if self.ax is None and kwargs.pop('ax', None) is None:
+ if self.ax is None and kwargs.pop('ax', None) is None:
import matplotlib.pyplot as plt
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
@@ -3025,7 +3025,7 @@
============== ====================================================
Keywords Description
============== ====================================================
- land_color desired land color (color name or rgba tuple).
+ land_color desired land color (color name or rgba tuple).
Default gray ("0.8").
ocean_color desired ocean color (color name or rgba tuple).
Default white.
@@ -3042,7 +3042,7 @@
lsmask_lats 1d array of latitudes for lsmask (ignored
if lsmask is None). Latitudes must be ordered
from -90 S northward.
- \**kwargs extra keyword arguments passed on to
+ \**kwargs extra keyword arguments passed on to
:meth:`imshow`
============== ====================================================
@@ -3089,7 +3089,7 @@
# redo the interpolation (unless a new land-sea mask is passed
# in via the lsmask, lsmask_lons, lsmask_lats keywords).
- # is it a cylindrical projection whose limits lie
+ # is it a cylindrical projection whose limits lie
# outside the limits of the image?
cylproj = self.projection in _cylproj and \
(self.urcrnrlon > lsmask_lons[-1] or \
@@ -3172,12 +3172,12 @@
If image is a URL (starts with 'http'), it is downloaded to a temp
file using urllib.urlretrieve.
- Default (if ``image`` not specified) is to display
+ Default (if ``image`` not specified) is to display
'blue marble next generation' image from http://visibleearth.nasa.gov/.
Specified image must have pixels covering the whole globe in a regular
lat/lon grid, starting and -180W and the South Pole.
- Works with the global images from
+ Works with the global images from
http://earthobservatory.nasa.gov/Features/BlueMarble/BlueMarble_monthlies.php.
The ``scale`` keyword can be used to downsample (rescale) the image.
@@ -3232,7 +3232,7 @@
delta = 360./float(nlons)
self._bm_lons = np.arange(-180.+0.5*delta,180.,delta)
self._bm_lats = np.arange(-90.+0.5*delta,90.,delta)
- # is it a cylindrical projection whose limits lie
+ # is it a cylindrical projection whose limits lie
# outside the limits of the image?
cylproj = self.projection in _cylproj and \
(self.urcrnrlon > self._bm_lons[-1] or \
@@ -3257,13 +3257,13 @@
if newfile or not hasattr(self,'_bm_rgba_warped'):
# transform to nx x ny regularly spaced native
# projection grid.
- # nx and ny chosen to have roughly the
+ # nx and ny chosen to have roughly the
# same horizontal res as original image.
if self.projection != 'cyl':
dx = 2.*np.pi*self.rmajor/float(nlons)
nx = int((self.xmax-self.xmin)/dx)+1
ny = int((self.ymax-self.ymin)/dx)+1
- else:
+ else:
dx = 360./float(nlons)
nx = int((self.urcrnrlon-self.llcrnrlon)/dx)+1
ny = int((self.urcrnrlat-self.llcrnrlat)/dx)+1
@@ -3322,9 +3322,9 @@
fontcolor='k',fillcolor1='w',fillcolor2='k',ax=None,\
format='%d'):
"""
- Draw a map scale at ``lon,lat`` of length ``length``
+ Draw a map scale at ``lon,lat`` of length ``length``
representing distance in the map
- projection coordinates at ``lon0,lat0``.
+ projection coordinates at ``lon0,lat0``.
.. tabularcolumns:: |l|L|
@@ -3334,24 +3334,24 @@
units the units of the length argument (Default km).
barstyle ``simple`` or ``fancy`` (roughly corresponding
to the styles provided by Generic Mapping Tools).
- Default ``simple``.
+ Default ``simple``.
fontsize for map scale annotations, default 9.
color for map scale annotations, default black.
labelstype ``simple`` (default) or ``fancy``. For
``fancy`` the map scale factor (ratio betwee
the actual distance and map projection distance
- at lon0,lat0) and the value of lon0,lat0 are also
- displayed on the top of the scale bar. For
+ at lon0,lat0) and the value of lon0,lat0 are also
+ displayed on the top of the scale bar. For
``simple``, just the units are display on top
and the distance below the scale bar.
If equal to False, plot an empty label.
format a string formatter to format numeric values
yoffset yoffset controls how tall the scale bar is,
and how far the annotations are offset from the
- scale bar. Default is 0.02 times the height of
+ scale bar. Default is 0.02 times the height of
the map (0.02*(self.ymax-self.ymin)).
fillcolor1(2) colors of the alternating filled regions
- (default white and black). Only relevant for
+ (default white and black). Only relevant for
'fancy' barstyle.
============== ====================================================
@@ -3365,7 +3365,7 @@
# convert length to meters
lenlab = length
if units == 'km':
- length = length*1000
+ length = length*1000
elif units == 'mi':
length = length*1609.344
elif units == 'nmi':
@@ -3592,7 +3592,7 @@
============== ====================================================
Arguments Description
============== ====================================================
- datain a rank-2 array with 1st dimension corresponding to
+ datain a rank-2 array with 1st dimension corresponding to
y, 2nd dimension x.
xin, yin rank-1 arrays containing x and y of
datain grid in increasing order.
@@ -3606,15 +3606,15 @@
============== ====================================================
checkbounds If True, values of xout and yout are checked to see
that they lie within the range specified by xin
- and xin.
- If False, and xout,yout are outside xin,yin,
+ and xin.
+ If False, and xout,yout are outside xin,yin,
interpolated values will be clipped to values on
boundary of input grid (xin,yin)
Default is False.
masked If True, points outside the range of xin and yin
- are masked (in a masked array).
+ are masked (in a masked array).
If masked is set to a number, then
- points outside the range of xin and yin will be
+ points outside the range of xin and yin will be
set to that number. Default False.
order 0 for nearest-neighbor interpolation, 1 for
bilinear interpolation (default 1).
@@ -3827,16 +3827,16 @@
In addition, variables that have the ``scale_factor`` and ``add_offset``
attribute will automatically be converted to and from short integers.
To suppress these automatic conversions, set the ``maskandscale``
- keyword to False.
+ keyword to False.
The keywords ``cache``, ``username``, ``password`` and ``verbose`` are only
- valid for remote OPenDAP datasets. ``username`` and ``password`` are used
+ valid for remote OPenDAP datasets. ``username`` and ``password`` are used
to access OPenDAP datasets that require authentication. ``verbose=True``
will make the pydap client print out the URLs being accessed.
``cache`` is a location (a directory) for caching data, so that repeated
- accesses to the same URL avoid the network.
+ accesses to the same URL avoid the network.
- The keyword ``mmap`` is only valid for local netCDF files. When
+ The keyword ``mmap`` is only valid for local netCDF files. When
``mmap=True`` (default), the mmap module is used to access the data.
This may be slow for very large netCDF variables.
"""
@@ -3851,8 +3851,8 @@
"""
Return datetime objects given numeric time values. The units
of the numeric time values are described by the ``units`` argument
- and the ``calendar`` keyword. The returned datetime objects represent
- UTC with no time-zone offset, even if the specified
+ and the ``calendar`` keyword. The returned datetime objects represent
+ UTC with no time-zone offset, even if the specified
units contain a time-zone offset.
Default behavior is the same as the matplotlib.dates.num2date function
@@ -3872,14 +3872,14 @@
============== ====================================================
Keywords Description
============== ====================================================
- units a string of the form '<time units> since
+ units a string of the form '<time units> since
<reference time>' describing the units and
origin of the time coordinate.
<time units> can be days, hours, minutes
- or seconds. <reference time> is the time origin.
+ or seconds. <reference time> is the time origin.
Default is 'days since 0001-01-01 00:00:00'.
calendar describes the calendar used in the time
- calculations. All the values currently defined in
+ calculations. All the values currently defined in
the CF metadata convention
(http://cf-pcmdi.llnl.gov/documents/cf-conventions/)
are supported.
@@ -3891,11 +3891,11 @@
Returns a datetime instance, or an array of datetime instances.
- The datetime instances returned are 'real' python datetime
- objects if the date falls in the Gregorian calendar (i.e.
+ The datetime instances returned are 'real' python datetime
+ objects if the date falls in the Gregorian calendar (i.e.
calendar=``proleptic_gregorian``, or calendar = ``standard``
or ``gregorian`` and the date is after 1582-10-15).
- Otherwise, they are 'phony' datetime
+ Otherwise, they are 'phony' datetime
objects which support some but not all the methods of 'real' python
datetime objects. The datetime instances do not contain
a time-zone offset, even if the specified units contains one.
@@ -3908,7 +3908,7 @@
Return numeric time values given datetime objects. The units
of the numeric time values are described by the ``units`` argument
and the ``calendar`` keyword. The datetime objects must
- be in UTC with no time-zone offset. If there is a
+ be in UTC with no time-zone offset. If there is a
time-zone offset in units, it will be applied to the
returned numeric values.
@@ -3931,14 +3931,14 @@
============== ====================================================
Keywords Description
============== ====================================================
- units a string of the form '<time units> since
+ units a string of the form '<time units> since
<reference time>' describing the units and
origin of the time coordinate.
<time units> can be days, hours, minutes
- or seconds. <reference time> is the time origin.
+ or seconds. <reference time> is the time origin.
Default is 'days since 0001-01-01 00:00:00'.
calendar describes the calendar used in the time
- calculations. All the values currently defined in
+ calculations. All the values currently defined in
the CF metadata convention
(http://cf-pcmdi.llnl.gov/documents/cf-conventions/)
are supported.
@@ -3977,7 +3977,7 @@
Keywords Description
============== ====================================================
calendar describes the calendar used in the time
- calculations. All the values currently defined in
+ calculations. All the values currently defined in
the CF metadata convention
(http://cf-pcmdi.llnl.gov/documents/cf-conventions/)
are supported.
@@ -3985,16 +3985,16 @@
``proleptic_gregorian``, ``noleap``, ``365_day``,
``julian``, ``all_leap``, ``366_day``.
If ``calendar=None``, will use ``calendar`` attribute
- of ``nctime`` object, and if that attribute does
- not exist calendar is set to ``standard``.
+ of ``nctime`` object, and if that attribute does
+ not exist calendar is set to ``standard``.
Default is ``None``.
select The index selection method. ``exact`` will return the
- indices perfectly matching the dates given.
+ indices perfectly matching the dates given.
``before`` and ``after`` will return the indices
corresponding to the dates just before or after
the given dates if an exact match cannot be found.
- ``nearest`` will return the indices that
- correspond to the closest dates. Default ``exact``.
+ ``nearest`` will return the indices that
+ correspond to the closest dates. Default ``exact``.
============== ====================================================
Returns an index or a sequence of indices.
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py 2009-12-07 01:17:27 UTC (rev 8011)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py 2009-12-08 02:02:49 UTC (rev 8012)
@@ -49,7 +49,7 @@
creates a Julian Day from a 'datetime-like' object. Returns the fractional
Julian Day (resolution 1 second).
-if calendar='standard' or 'gregorian' (default), Julian day follows Julian
+if calendar='standard' or 'gregorian' (default), Julian day follows Julian
Calendar on and before 1582-10-5, Gregorian calendar after 1582-10-15.
if calendar='proleptic_gregorian', Julian Day follows gregorian calendar.
@@ -62,7 +62,7 @@
Virginia. p. 63
"""
-
+
# based on redate.py by David Finlayson.
year=date.year; month=date.month; day=date.day
@@ -74,13 +74,13 @@
if (month < 3):
month = month + 12
year = year - 1
-
+
A = int(year/100)
jd = int(365.25 * (year + 4716)) + int(30.6001 * (month + 1)) + \
day - 1524.5
- # optionally adjust the jd for the switch from
+ # optionally adjust the jd for the switch from
# the Julian to Gregorian Calendar
# here assumed to have occurred the day after 1582 October 4
if calendar in ['standard','gregorian']:
@@ -98,21 +98,21 @@
B = 0
else:
raise ValueError, 'unknown calendar, must be one of julian,standard,gregorian,proleptic_gregorian, got %s' % calendar
-
+
# adjust for Julian calendar if necessary
jd = jd + B
-
- return jd
+ return jd
+
def _NoLeapDayFromDate(date):
"""
-creates a Julian Day for a calendar with no leap years from a datetime
+creates a Julian Day for a calendar with no leap years from a datetime
instance. Returns the fractional Julian Day (resolution 1 second).
"""
-
+
year=date.year; month=date.month; day=date.day
hour=date.hour; minute=date.minute; second=date.second
# Convert time to fractions of a day
@@ -122,12 +122,12 @@
if (month < 3):
month = month + 12
year = year - 1
-
+
jd = int(365. * (year + 4716)) + int(30.6001 * (month + 1)) + \
day - 1524.5
-
- return jd
+ return jd
+
def _AllLeapFromDate(date):
"""
@@ -137,7 +137,7 @@
Returns the fractional Julian Day (resolution 1 second).
"""
-
+
year=date.year; month=date.month; day=date.day
hour=date.hour; minute=date.minute; second=date.second
# Convert time to fractions of a day
@@ -147,12 +147,12 @@
if (month < 3):
month = month + 12
year = year - 1
-
+
jd = int(366. * (year + 4716)) + int(30.6001 * (month + 1)) + \
day - 1524.5
-
- return jd
+ return jd
+
def _360DayFromDate(date):
"""
@@ -162,23 +162,23 @@
Returns the fractional Julian Day (resolution 1 second).
"""
-
+
year=date.year; month=date.month; day=date.day
hour=date.hour; minute=date.minute; second=date.second
# Convert time to fractions of a day
day = day + hour/24.0 + minute/1440.0 + second/86400.0
jd = int(360. * (year + 4716)) + int(30. * (month - 1)) + day
-
- return jd
+ return jd
+
def DateFromJulianDay(JD,calendar='standard'):
"""
-returns a 'datetime-like' object given Julian Day. Julian Day is a
+returns a 'datetime-like' object given Julian Day. Julian Day is a
fractional day with a resolution of 1 second.
-if calendar='standard' or 'gregorian' (default), Julian day follows Julian
+if calendar='standard' or 'gregorian' (default), Julian day follows Julian
Calendar on and before 1582-10-5, Gregorian calendar after 1582-10-15.
if calendar='proleptic_gregorian', Julian Day follows gregorian calendar.
@@ -200,7 +200,7 @@
"""
# based on redate.py by David Finlayson.
-
+
if JD < 0:
raise ValueError, 'Julian Day must be positive'
@@ -250,18 +250,18 @@
leap = 1
if calendar == 'proleptic_gregorian' or \
(calendar in ['standard','gregorian'] and JD >= 2299160.5):
- if year % 100 == 0 and year % 400 != 0:
+ if year % 100 == 0 and year % 400 != 0:
print year % 100, year % 400
leap = 0
if leap and month > 2:
dayofyr = dayofyr + leap
-
- # Convert fractions of a day to time
+
+ # Convert fractions of a day to time
(dfrac, days) = math.modf(day/1.0)
(hfrac, hours) = math.modf(dfrac * 24.0)
(mfrac, minutes) = math.modf(hfrac * 60.0)
seconds = round(mfrac * 60.0) # seconds are rounded
-
+
if seconds > 59:
seconds = 0
minutes = minutes + 1
@@ -271,7 +271,7 @@
if hours > 23:
hours = 0
days = days + 1
-
+
# return a 'real' datetime instance if calendar is gregorian.
if calendar == 'proleptic_gregorian' or \
(calendar in ['standard','gregorian'] and JD >= 2299160.5):
@@ -283,13 +283,13 @@
def _DateFromNoLeapDay(JD):
"""
-returns a 'datetime-like' object given Julian Day for a calendar with no leap
+returns a 'datetime-like' object given Julian Day for a calendar with no leap
days. Julian Day is a fractional day with a resolution of 1 second.
"""
# based on redate.py by David Finlayson.
-
+
if JD < 0:
raise ValueError, 'Julian Day must be positive'
@@ -318,13 +318,13 @@
year = C - 4716
else:
year = C - 4715
-
- # Convert fractions of a day to time
+
+ # Convert fractions of a day to time
(dfrac, days) = math.modf(day/1.0)
(hfrac, hours) = math.modf(dfrac * 24.0)
(mfrac, minutes) = math.modf(hfrac * 60.0)
seconds = round(mfrac * 60.0) # seconds are rounded
-
+
if seconds > 59:
seconds = 0
minutes = minutes + 1
@@ -334,7 +334,7 @@
if hours > 23:
hours = 0
days = days + 1
-
+
return datetime(year,month,int(days),int(hours),int(minutes),int(seconds), dayofwk, dayofyr)
def _DateFromAllLeap(JD):
@@ -347,7 +347,7 @@
"""
# based on redate.py by David Finlayson.
-
+
if JD < 0:
raise ValueError, 'Julian Day must be positive'
@@ -378,13 +378,13 @@
year = C - 4716
else:
year = C - 4715
-
- # Convert fractions of a day to time
+
+ # Convert fractions of a day to time
(dfrac, days) = math.modf(day/1.0)
(hfrac, hours) = math.modf(dfrac * 24.0)
(mfrac, minutes) = math.modf(hfrac * 60.0)
seconds = round(mfrac * 60.0) # seconds are rounded
-
+
if seconds > 59:
seconds = 0
minutes = minutes + 1
@@ -394,7 +394,7 @@
if hours > 23:
hours = 0
days = days + 1
-
+
return datetime(year,month,int(days),int(hours),int(minutes),int(seconds), dayofwk, dayofyr)
def _DateFrom360Day(JD):
@@ -412,16 +412,16 @@
#jd = int(360. * (year + 4716)) + int(30. * (month - 1)) + day
(F, Z) = math.modf(JD)
year = int((Z-0.5)/360.) - 4716
- dayofyr = JD - (year+4716)*360
+ dayofyr = JD - (year+4716)*360
month = int((dayofyr-0.5)/30)+1
- day = dayofyr - (month-1)*30 + F
-
- # Convert fractions of a day to time
+ day = dayofyr - (month-1)*30 + F
+
+ # Convert fractions of a day to time
(dfrac, days) = math.modf(day/1.0)
(hfrac, hours) = math.modf(dfrac * 24.0)
(mfrac, minutes) = math.modf(hfrac * 60.0)
seconds = round(mfrac * 60.0) # seconds are rounded
-
+
if seconds > 59:
seconds = 0
minutes = minutes + 1
@@ -431,7 +431,7 @@
if hours > 23:
hours = 0
days = days + 1
-
+
return datetime(year,month,int(days),int(hours),int(minutes),int(seconds),-1, int(dayofyr))
def _dateparse(timestr):
@@ -455,20 +455,20 @@
To initialize: C{t = utime(unit_string,calendar='standard')}
-where
+where
B{C{unit_string}} is a string of the form
C{'time-units since <time-origin>'} defining the time units.
-Valid time-units are days, hours, minutes and seconds (the singular forms
-are also accepted). An example unit_string would be C{'hours
+Valid time-units are days, hours, minutes and seconds (the singular forms
+are also accepted). An example unit_string would be C{'hours
since 0001...
[truncated message content] |
|
From: <lee...@us...> - 2009-12-07 01:17:34
|
Revision: 8011
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8011&view=rev
Author: leejjoon
Date: 2009-12-07 01:17:27 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
update CHANGELOG for the axes_grid change
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-12-07 01:17:16 UTC (rev 8010)
+++ trunk/matplotlib/CHANGELOG 2009-12-07 01:17:27 UTC (rev 8011)
@@ -1,3 +1,6 @@
+2009-12-06 axes_grid: reimplemented AxisArtist with FloatingAxes support.
+ Added new examples. - JJL
+
2009-12-01 Applied Laurent Dufrechou's patch to improve blitting with
the qt4 backend - DSD
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|