SF.net SVN: matplotlib:[6372] trunk/matplotlib
Revision: 6372
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6372&view=rev
Author: mdboom
Date: 2008-11-07 14:52:04 + (Fri, 07 Nov 2008)
Log Message:
---
Committed Andrew Straw's patch to support hyperlinks. Currently only the SVG
backend, but the infrastructure is there for other backends to support it.
Modified Paths:
--
trunk/matplotlib/lib/matplotlib/artist.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
trunk/matplotlib/lib/matplotlib/collections.py
trunk/matplotlib/lib/matplotlib/image.py
trunk/matplotlib/lib/matplotlib/patches.py
trunk/matplotlib/lib/matplotlib/text.py
trunk/matplotlib/src/_backend_agg.cpp
Added Paths:
---
trunk/matplotlib/examples/pylab_examples/hyperlinks.py
Added: trunk/matplotlib/examples/pylab_examples/hyperlinks.py
===
--- trunk/matplotlib/examples/pylab_examples/hyperlinks.py
(rev 0)
+++ trunk/matplotlib/examples/pylab_examples/hyperlinks.py 2008-11-07
14:52:04 UTC (rev 6372)
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# -*- noplot -*-
+
+"""
+This example demonstrates how to set a hyperlinks on various kinds of elements.
+
+This currently only works with the SVG backend.
+"""
+
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+
+f = plt.figure()
+s = plt.scatter([1,2,3],[4,5,6])
+s.set_urls(['http://www.bbc.co.uk/news','http://www.google.com',None])
+f.canvas.print_figure('scatter.svg')
+
+f = plt.figure()
+delta = 0.025
+x = y = np.arange(-3.0, 3.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+Z = Z2-Z1 # difference of Gaussians
+
+im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
+origin='lower', extent=[-3,3,-3,3])
+
+im.set_url('http://www.google.com')
+f.canvas.print_figure('image.svg')
+
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===
--- trunk/matplotlib/lib/matplotlib/artist.py 2008-11-07 13:31:25 UTC (rev
6371)
+++ trunk/matplotlib/lib/matplotlib/artist.py 2008-11-07 14:52:04 UTC (rev
6372)
@@ -50,6 +50,7 @@
self._propobservers = {} # a dict from oids to funcs
self.axes = None
self._remove_method = None
+self._url = None
def remove(self):
"""
@@ -313,6 +314,18 @@
"""
return self.figure is not None
+def get_url(self):
+"""
+Returns the url
+"""
+return self._url
+
+def set_url(self, url):
+"""
+Sets the url for the artist
+"""
+self._url = url
+
def get_figure(self):
"""
Return the :class:`~matplotlib.figure.Figure` instance the
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-11-07 13:31:25 UTC (rev
6371)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-11-07 14:52:04 UTC (rev
6372)
@@ -5480,7 +5480,7 @@
def imshow(self, X, cmap=None, norm=None, aspect=None,
interpolation=None, alpha=1.0, vmin=None, vmax=None,
origin=None, extent=None, shape=None, filternorm=1,
- filterrad=4.0, imlim=None, resample=None, **kwargs):
+ filterrad=4.0, imlim=None, resample=None, url=None, **kwargs):
"""
call signature::
@@ -5601,6 +5601,7 @@
im.set_clim(vmin, vmax)
else:
im.autoscale_None()
+im.set_url(url)
xmin, xmax, ymin, ymax = im.get_extent()
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===
--- trunk/matplotlib/lib/matplotlib/backend_bases.py2008-11-07 13:31:25 UTC
(rev 6371)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py2008-11-07 14:52:04 UTC
(rev 6372)
@@ -107,7 +107,7 @@
def draw_path_collection(self, master_transform, cliprect, clippath,
clippath_trans, paths, all_transforms, offsets,
offsetTrans, facecolors, edgecolors, linewidths,
- linestyles, antialiaseds):
+ linestyles, antialiaseds, urls):
"""
Draws a collection of paths, selecting drawing properties from
the lists *facecolors*, *edgecolors*, *linewidths*,
@@ -136,7 +136,7 @@
for xo, yo, path_id, gc, rgbFace in self._iter_collection(
path_ids, cliprect, clippath, clippath_trans,
offsets, offsetTrans, facecolo
SF.net SVN: matplotlib:[6373] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap/pupynere.py
Revision: 6373
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6373&view=rev
Author: jswhit
Date: 2008-11-07 16:53:31 + (Fri, 07 Nov 2008)
Log Message:
---
update to version 1.0.6
Modified Paths:
--
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
===
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py 2008-11-07
14:52:04 UTC (rev 6372)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py 2008-11-07
16:53:31 UTC (rev 6373)
@@ -127,9 +127,10 @@
attribute of the ``netcdf_file`` object.
"""
-def __init__(self, filename, mode='r', maskandscale=False):
+def __init__(self, filename, mode='r', mmap=True, maskandscale=False):
+self.filename = filename
+self.use_mmap = mmap
self._maskandscale = maskandscale
-self.filename = filename
assert mode in 'rw', "Mode must be either 'r' or 'w'."
self.mode = mode
@@ -202,7 +203,7 @@
def _write_numrecs(self):
# Get highest record count from all record variables.
for var in self.variables.values():
-if not var._shape[0] and len(var.data) > self._recs:
+if var.isrec and len(var.data) > self._recs:
self.__dict__['_recs'] = len(var.data)
self._pack_int(self._recs)
@@ -210,8 +211,9 @@
if self.dimensions:
self.fp.write(NC_DIMENSION)
self._pack_int(len(self.dimensions))
-for name, length in self.dimensions.items():
+for name in self._dims:
self._pack_string(name)
+length = self.dimensions[name]
self._pack_int(length or 0) # replace None with 0 for record
dimension
else:
self.fp.write(ABSENT)
@@ -236,7 +238,7 @@
# Sort variables non-recs first, then recs.
variables = self.variables.items()
-variables.sort(key=lambda (k, v): v._shape and v._shape[0] is not
None)
+variables.sort(key=lambda (k, v): v._shape and not v.isrec)
variables.reverse()
variables = [k for (k, v) in variables]
@@ -247,7 +249,7 @@
# each record variable, so we can calculate recsize.
self.__dict__['_recsize'] = sum([
var._vsize for var in self.variables.values()
-if var._shape[0] is None])
+if var.isrec])
# Set the data for all variables.
for name in variables:
self._write_var_data(name)
@@ -268,13 +270,16 @@
nc_type = REVERSE[var.typecode()]
self.fp.write(nc_type)
-if var._shape[0]:
+if not var.isrec:
vsize = var.data.size * var.data.itemsize
vsize += -vsize % 4
else: # record variable
-vsize = var.data[0].size * var.data.itemsize
+try:
+vsize = var.data[0].size * var.data.itemsize
+except IndexError:
+vsize = 0
rec_vars = len([var for var in self.variables.values()
-if var._shape[0] is None])
+if var.isrec])
if rec_vars > 1:
vsize += -vsize % 4
self.variables[name].__dict__['_vsize'] = vsize
@@ -294,7 +299,7 @@
self.fp.seek(the_beguine)
# Write data.
-if var._shape[0]:
+if not var.isrec:
self.fp.write(var.data.tostring())
count = var.data.size * var.data.itemsize
self.fp.write('0' * (var._vsize - count))
@@ -405,9 +410,16 @@
# Data will be set later.
data = None
else:
-mm = mmap(self.fp.fileno(), begin_+vsize, access=ACCESS_READ)
-data = ndarray.__new__(ndarray, shape, dtype=dtype_,
-buffer=mm, offset=begin_, order=0)
+if self.use_mmap:
+mm = mmap(self.fp.fileno(), begin_+vsize,
access=ACCESS_READ)
+data = ndarray.__new__(ndarray, shape, dtype=dtype_,
+buffer=mm, offset=begin_, order=0)
+else:
+pos = self.fp.tell()
+self.fp.seek(begin_)
+data = fromstring(self.fp.read(vsize), dtype=dtype_)
+data.shape = shape
+self.fp.seek(pos)
# Add variable.
self.variables[name] = netcdf_variable(
@@ -420,9 +432,16 @@
dtypes['formats'] = dtypes['formats'][:1]
# Build rec array.
-mm = mmap(self.fp.fileno(), begin+self._recs*self._recsize,
access=ACCESS_READ)
-rec_array = ndarray.__new__(ndarray, (self._recs,), dtype=dtypes,
-
SF.net SVN: matplotlib:[6369] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap/__init__.py
Revision: 6369 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6369&view=rev Author: jswhit Date: 2008-11-07 12:30:08 + (Fri, 07 Nov 2008) Log Message: --- added masked array support to addcyclic function (thanks to Jesper Larsen) 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 2008-11-06 22:53:02 UTC (rev 6368) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-11-07 12:30:08 UTC (rev 6369) @@ -3679,8 +3679,14 @@ if lon0 < lonsin[0] or lon0 > lonsin[-1]: raise ValueError, 'lon0 outside of range of lonsin' i0 = np.argmin(np.fabs(lonsin-lon0)) -dataout = np.zeros(datain.shape,datain.dtype) -lonsout = np.zeros(lonsin.shape,lonsin.dtype) +if hasattr(datain,'mask'): +datout = ma.zeros((nlats,nlons+1),datain.dtype) +else: +datout = np.zeros((nlats,nlons+1),datain.dtype) +if hasattr(lonsin,'mask'): +lonsout = ma.zeros(nlons+1,lonsin.dtype) +else: +lonsout = np.zeros(nlons+1,lonsin.dtype) if start: lonsout[0:len(lonsin)-i0] = lonsin[i0:] else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6370] trunk/toolkits/basemap
Revision: 6370 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6370&view=rev Author: jswhit Date: 2008-11-07 12:36:37 + (Fri, 07 Nov 2008) Log Message: --- Added masked array support to shiftgrid, fix cut and paste error in previous commit. Patch provided by Jesper Larsen. Modified Paths: -- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/Changelog === --- trunk/toolkits/basemap/Changelog2008-11-07 12:30:08 UTC (rev 6369) +++ trunk/toolkits/basemap/Changelog2008-11-07 12:36:37 UTC (rev 6370) @@ -1,4 +1,6 @@ version 0.99.2 (not yet released) + * Added masked array support to shiftgrid function + (thanks to Jesper Larsen). * defer import of netcdf stuff till it is needed (in NetCDFFile function). * Added McBryde-Thomas Flat Polar Quartic (projection = Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py === --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-11-07 12:30:08 UTC (rev 6369) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-11-07 12:36:37 UTC (rev 6370) @@ -3680,13 +3680,13 @@ raise ValueError, 'lon0 outside of range of lonsin' i0 = np.argmin(np.fabs(lonsin-lon0)) if hasattr(datain,'mask'): -datout = ma.zeros((nlats,nlons+1),datain.dtype) +dataout = ma.zeros(datain.shape,datain.dtype) else: -datout = np.zeros((nlats,nlons+1),datain.dtype) +dataout = np.zeros(datain.shape,datain.dtype) if hasattr(lonsin,'mask'): -lonsout = ma.zeros(nlons+1,lonsin.dtype) +lonsout = ma.zeros(lonsin.shape,lonsin.dtype) else: -lonsout = np.zeros(nlons+1,lonsin.dtype) +lonsout = np.zeros(lonsin.shape,lonsin.dtype) if start: lonsout[0:len(lonsin)-i0] = lonsin[i0:] else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6371] trunk/matplotlib/lib/matplotlib/artist.py
Revision: 6371 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6371&view=rev Author: mdboom Date: 2008-11-07 13:31:25 + (Fri, 07 Nov 2008) Log Message: --- Minor docstring fix. Modified Paths: -- trunk/matplotlib/lib/matplotlib/artist.py Modified: trunk/matplotlib/lib/matplotlib/artist.py === --- trunk/matplotlib/lib/matplotlib/artist.py 2008-11-07 12:36:37 UTC (rev 6370) +++ trunk/matplotlib/lib/matplotlib/artist.py 2008-11-07 13:31:25 UTC (rev 6371) @@ -569,8 +569,8 @@ pyplot signature: findobj(o=gcf(), match=None) -recursively find all :class:matplotlib.artist.Artist instances -contained in self +Recursively find all :class:matplotlib.artist.Artist instances +contained in self. *match* can be @@ -812,16 +812,16 @@ def findobj(self, match=None): """ -recursively find all :class:matplotlib.artist.Artist instances -contained in self +Recursively find all :class:`matplotlib.artist.Artist` +instances contained in *self*. -if *match* is not None, it can be +If *match* is not None, it can be - function with signature ``boolean = match(artist)`` - - class instance: eg Line2D + - class instance: eg :class:`~matplotlib.lines.Line2D` -used to filter matches +used to filter matches. """ if match is None: # always return True @@ -861,7 +861,6 @@ getp(o) # get all the object properties getp(o, 'linestyle') # get the linestyle property - *o* is a :class:`Artist` instance, eg :class:`~matplotllib.lines.Line2D` or an instance of a :class:`~matplotlib.axes.Axes` or :class:`matplotlib.text.Text`. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
