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: <js...@us...> - 2008-04-11 14:56:42
|
Revision: 5036
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5036&view=rev
Author: jswhit
Date: 2008-04-11 07:56:32 -0700 (Fri, 11 Apr 2008)
Log Message:
-----------
added Jesper Larson to contributors list.
Modified Paths:
--------------
trunk/toolkits/basemap/README
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-04-11 14:55:33 UTC (rev 5035)
+++ trunk/toolkits/basemap/README 2008-04-11 14:56:32 UTC (rev 5036)
@@ -115,5 +115,6 @@
Ivan Lima
Erik Andersen
Michael Hearne
+Jesper Larsen
for valuable contributions.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-04-11 14:55:50
|
Revision: 5035
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5035&view=rev
Author: jswhit
Date: 2008-04-11 07:55:33 -0700 (Fri, 11 Apr 2008)
Log Message:
-----------
fix bug in pupynere.py creating masked arrays when both _FillValue and missing_value exist.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-04-11 14:54:43 UTC (rev 5034)
+++ trunk/toolkits/basemap/Changelog 2008-04-11 14:55:33 UTC (rev 5035)
@@ -1,4 +1,6 @@
version 0.99
+ * fixed bug in NetCDFFile creating masked arrays when both
+ _FillValue and missing_value exist.
* drawparallels and drawmeridians return a dictionary containing
the Line2D and Text instances associated with each lat or lon.
* drawcoastlines, drawcountries and friends now have
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-04-11 14:54:46
|
Revision: 5034
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5034&view=rev
Author: jswhit
Date: 2008-04-11 07:54:43 -0700 (Fri, 11 Apr 2008)
Log Message:
-----------
fix bug in pupynere.py creating masked arrays when both _FillValue and missing_value exist.
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-04-09 18:54:54 UTC (rev 5033)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py 2008-04-11 14:54:43 UTC (rev 5034)
@@ -31,7 +31,7 @@
import itertools
import mmap
-from numpy import ndarray, empty, array, ma, squeeze, zeros
+from numpy import ndarray, empty, array, ma, squeeze, zeros
import numpy
from dap.client import open as open_remote
@@ -113,15 +113,15 @@
fillval = None
if hasattr(var, 'missing_value') and (datout == var.missing_value).any():
fillval = var.missing_value
- totalmask = totalmask + datout==fillval
+ totalmask += datout==fillval
if hasattr(var, '_FillValue') and (datout == var._FillValue).any():
if fillval is None:
fillval = var._FillValue
- totalmask = totalmask + datout==var._FillValue
+ totalmask += datout==var._FillValue
elif (datout == _default_fillvals[var.typecode()]).any():
if fillval is None:
fillval = _default_fillvals[var.typecode()]
- totalmask = totalmask + datout==_default_fillvals[var.dtype]
+ totalmask += datout==_default_fillvals[var.dtype]
if fillval is not None:
datout = ma.masked_array(datout,mask=totalmask,fill_value=fillval)
try:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-09 18:54:57
|
Revision: 5033
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5033&view=rev
Author: jdh2358
Date: 2008-04-09 11:54:54 -0700 (Wed, 09 Apr 2008)
Log Message:
-----------
small fix for vlines w/ len 1 args
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/axes.py
Modified: branches/v0_91_maint/lib/matplotlib/axes.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/axes.py 2008-04-07 22:26:21 UTC (rev 5032)
+++ branches/v0_91_maint/lib/matplotlib/axes.py 2008-04-09 18:54:54 UTC (rev 5033)
@@ -2442,10 +2442,11 @@
y = npy.asarray(y)
if len(xmin)==1:
- xmin = xmin*npy.ones(y.shape, y.dtype)
+ xmin = npy.resize( xmin, y.shape )
if len(xmax)==1:
- xmax = xmax*npy.ones(y.shape, y.dtype)
+ xmax = npy.resize( xmax, y.shape )
+
xmin = npy.asarray(xmin)
xmax = npy.asarray(xmax)
@@ -2512,7 +2513,12 @@
ymin = npy.asarray(ymin)
ymax = npy.asarray(ymax)
+ if len(ymin)==1:
+ ymin = npy.resize( ymin, x.shape )
+ if len(ymax)==1:
+ ymax = npy.resize( ymax, x.shape )
+
if len(ymin)!=len(x):
raise ValueError, 'ymin and x are unequal sized sequences'
if len(ymax)!=len(x):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jr...@us...> - 2008-04-07 22:26:24
|
Revision: 5032
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5032&view=rev
Author: jrevans
Date: 2008-04-07 15:26:21 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Fixed the double draw bug.
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/backends/backend_qt4agg.py
branches/v0_91_maint/lib/matplotlib/backends/backend_qtagg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_qt4agg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_qt4agg.py 2008-04-07 22:25:37 UTC (rev 5031)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_qt4agg.py 2008-04-07 22:26:21 UTC (rev 5032)
@@ -129,7 +129,6 @@
if DEBUG: print "FigureCanvasQtAgg.draw", self
self.replot = True
FigureCanvasAgg.draw(self)
- self.update()
def blit(self, bbox=None):
"""
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_qtagg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_qtagg.py 2008-04-07 22:25:37 UTC (rev 5031)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_qtagg.py 2008-04-07 22:26:21 UTC (rev 5032)
@@ -135,7 +135,6 @@
if DEBUG: print "FigureCanvasQtAgg.draw", self
self.replot = True
FigureCanvasAgg.draw(self)
- self.repaint( False )
def blit(self, bbox=None):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jr...@us...> - 2008-04-07 22:25:41
|
Revision: 5031
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5031&view=rev
Author: jrevans
Date: 2008-04-07 15:25:37 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Edited so that a double draw does not occur.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py
trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-04-07 18:48:02 UTC (rev 5030)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-04-07 22:25:37 UTC (rev 5031)
@@ -130,7 +130,7 @@
if DEBUG: print "FigureCanvasQtAgg.draw", self
self.replot = True
- self.update()
+ FigureCanvasAgg.draw(self)
def blit(self, bbox=None):
"""
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-04-07 18:48:02 UTC (rev 5030)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-04-07 22:25:37 UTC (rev 5031)
@@ -135,7 +135,7 @@
if DEBUG: print "FigureCanvasQtAgg.draw", self
self.replot = True
- self.repaint( False )
+ FigureCanvasAgg.draw(self)
def blit(self, bbox=None):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-07 18:48:12
|
Revision: 5030
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5030&view=rev
Author: efiring
Date: 2008-04-07 11:48:02 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
improve color validation in rc handling
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/rcsetup.py
trunk/matplotlib/matplotlibrc.template
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-04 15:02:48 UTC (rev 5029)
+++ trunk/matplotlib/CHANGELOG 2008-04-07 18:48:02 UTC (rev 5030)
@@ -1,6 +1,9 @@
+2008-04-07 Improve color validation in rc handling, suggested
+ by Lev Givon - EF
+
2008-04-02 Allow to use both linestyle definition arguments, '-' and
- 'solid' etc. in plots/collections - MM
-
+ 'solid' etc. in plots/collections - MM
+
2008-03-27 Fix saving to Unicode filenames with Agg backend
(other backends appear to already work...)
(Thanks, Christopher Barker) - MGD
Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-04-04 15:02:48 UTC (rev 5029)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-04-07 18:48:02 UTC (rev 5030)
@@ -10,6 +10,7 @@
import os
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
+from matplotlib.colors import is_color_like
class ValidateInStrings:
def __init__(self, key, valid, ignorecase=False):
@@ -122,37 +123,35 @@
return [int(val) for val in s]
-
def validate_color(s):
'return a valid color arg'
- if s.lower() == 'none': return 'None'
- if len(s)==1 and s.isalpha(): return s
- if s.find(',')>=0: # looks like an rgb
+ if s.lower() == 'none':
+ return 'None'
+ if is_color_like(s):
+ return s
+ stmp = '#' + s
+ if is_color_like(stmp):
+ return stmp
+ # If it is still valid, it must be a tuple.
+ colorarg = s
+ msg = ''
+ if s.find(',')>=0:
# get rid of grouping symbols
- s = ''.join([ c for c in s if c.isdigit() or c=='.' or c==','])
- vals = s.split(',')
+ stmp = ''.join([ c for c in s if c.isdigit() or c=='.' or c==','])
+ vals = stmp.split(',')
if len(vals)!=3:
- raise ValueError('Color tuples must be length 3')
+ msg = '\nColor tuples must be length 3'
+ else:
+ try:
+ colorarg = [float(val) for val in vals]
+ except ValueError:
+ msg = '\nCould not convert all entries to floats'
- try: return [float(val) for val in vals]
- except ValueError:
- raise ValueError('Could not convert all entries "%s" to floats'%s)
+ if not msg and is_color_like(colorarg):
+ return colorarg
- if s.replace('.', '').isdigit(): # looks like scalar (grayscale)
- return s
+ raise ValueError('%s does not look like a color arg%s'%(s, msg))
- if len(s)==6 and s.isalnum(): # looks like hex
- return '#' + s
-
- if len(s)==7 and s.startswith('#') and s[1:].isalnum():
- return s
-
- if s.isalpha():
- #assuming a color name, hold on
- return s
-
- raise ValueError('%s does not look like color arg'%s)
-
def validate_stringlist(s):
'return a list'
if type(s) is str:
Modified: trunk/matplotlib/matplotlibrc.template
===================================================================
--- trunk/matplotlib/matplotlibrc.template 2008-04-04 15:02:48 UTC (rev 5029)
+++ trunk/matplotlib/matplotlibrc.template 2008-04-07 18:48:02 UTC (rev 5030)
@@ -19,7 +19,7 @@
# Colors: for the color values below, you can either use
# - a matplotlib color string, such as r, k, or b
# - an rgb tuple, such as (1.0, 0.5, 0.0)
-# - a hex string, such as ff00ff (no '#' symbol)
+# - a hex string, such as ff00ff or #ff00ff
# - a scalar grayscale intensity such as 0.75
# - a legal html color name, eg red, blue, darkslategray
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-04-04 15:02:53
|
Revision: 5029
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5029&view=rev
Author: jswhit
Date: 2008-04-04 08:02:48 -0700 (Fri, 04 Apr 2008)
Log Message:
-----------
workaround for problem reported by Rob Hetland
(meridians don't reach edge of very tiny maps)
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py 2008-04-03 15:24:20 UTC (rev 5028)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py 2008-04-04 15:02:48 UTC (rev 5029)
@@ -1587,10 +1587,13 @@
lats = circ*npy.ones(len(lons),npy.float32)
x,y = self(lons,lats)
# remove points outside domain.
- testx = npy.logical_and(x>=self.xmin-xdelta,x<=self.xmax+xdelta)
+ # leave a little slop around edges (3*xdelta)
+ # don't really know why, but this appears to be needed to
+ # or lines sometimes don't reach edge of plot.
+ testx = npy.logical_and(x>=self.xmin-3*xdelta,x<=self.xmax+3*xdelta)
x = npy.compress(testx, x)
y = npy.compress(testx, y)
- testy = npy.logical_and(y>=self.ymin-ydelta,y<=self.ymax+ydelta)
+ testy = npy.logical_and(y>=self.ymin-3*ydelta,y<=self.ymax+3*ydelta)
x = npy.compress(testy, x)
y = npy.compress(testy, y)
lines = []
@@ -1812,10 +1815,13 @@
lons = merid*npy.ones(len(lats),npy.float32)
x,y = self(lons,lats)
# remove points outside domain.
- testx = npy.logical_and(x>=self.xmin-xdelta,x<=self.xmax+xdelta)
+ # leave a little slop around edges (3*xdelta)
+ # don't really know why, but this appears to be needed to
+ # or lines sometimes don't reach edge of plot.
+ testx = npy.logical_and(x>=self.xmin-3*xdelta,x<=self.xmax+3*xdelta)
x = npy.compress(testx, x)
y = npy.compress(testx, y)
- testy = npy.logical_and(y>=self.ymin-ydelta,y<=self.ymax+ydelta)
+ testy = npy.logical_and(y>=self.ymin-3*ydelta,y<=self.ymax+3*ydelta)
x = npy.compress(testy, x)
y = npy.compress(testy, y)
lines = []
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-03 15:25:28
|
Revision: 5028
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5028&view=rev
Author: jdh2358
Date: 2008-04-03 08:24:20 -0700 (Thu, 03 Apr 2008)
Log Message:
-----------
some small fixes to excel tools
Modified Paths:
--------------
branches/v0_91_maint/examples/rec_groupby_demo.py
branches/v0_91_maint/lib/matplotlib/mlab.py
branches/v0_91_maint/lib/matplotlib/toolkits/exceltools.py
Modified: branches/v0_91_maint/examples/rec_groupby_demo.py
===================================================================
--- branches/v0_91_maint/examples/rec_groupby_demo.py 2008-04-02 13:33:21 UTC (rev 5027)
+++ branches/v0_91_maint/examples/rec_groupby_demo.py 2008-04-03 15:24:20 UTC (rev 5028)
@@ -6,14 +6,20 @@
r.sort()
def daily_return(prices):
+ 'an array of daily returns from price array'
g = np.zeros_like(prices)
g[1:] = (prices[1:]-prices[:-1])/prices[:-1]
return g
def volume_code(volume):
+ 'code the continuous volume data categorically'
ind = np.searchsorted([1e5,1e6, 5e6,10e6, 1e7], volume)
return ind
+# a list of (dtype_name, summary_function, output_dtype_name).
+# rec_summarize will call on each function on the indicated recarray
+# attribute, and the result assigned to output name in the return
+# record array.
summaryfuncs = (
('date', lambda x: [thisdate.year for thisdate in x], 'years'),
('date', lambda x: [thisdate.month for thisdate in x], 'months'),
@@ -24,6 +30,10 @@
rsum = mlab.rec_summarize(r, summaryfuncs)
+# stats is a list of (dtype_name, function, output_dtype_name).
+# rec_groupby will summarize the attribute identified by the
+# dtype_name over the groups in the groupby list, and assign the
+# result to the output_dtype_name
stats = (
('dreturn', len, 'rcnt'),
('dreturn', np.mean, 'rmean'),
@@ -31,6 +41,7 @@
('dreturn', np.std, 'rsigma'),
)
+# you can summarize over a single variable, like years or months
print 'summary by years'
ry = mlab.rec_groupby(rsum, ('years',), stats)
print mlab. rec2txt(ry)
@@ -39,6 +50,7 @@
rm = mlab.rec_groupby(rsum, ('months',), stats)
print mlab.rec2txt(rm)
+# or over multiple variables like years and months
print 'summary by year and month'
rym = mlab.rec_groupby(rsum, ('years','months'), stats)
print mlab.rec2txt(rym)
Modified: branches/v0_91_maint/lib/matplotlib/mlab.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/mlab.py 2008-04-02 13:33:21 UTC (rev 5027)
+++ branches/v0_91_maint/lib/matplotlib/mlab.py 2008-04-03 15:24:20 UTC (rev 5028)
@@ -1944,6 +1944,13 @@
else: return b
+def safe_isinf(x):
+ 'isnan for arbitrary types'
+ try: b = npy.isinf(x)
+ except NotImplementedError: return False
+ else: return b
+
+
def rec_append_field(rec, name, arr, dtype=None):
'return a new record array with field name populated with data from array arr'
arr = npy.asarray(arr)
Modified: branches/v0_91_maint/lib/matplotlib/toolkits/exceltools.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/toolkits/exceltools.py 2008-04-02 13:33:21 UTC (rev 5027)
+++ branches/v0_91_maint/lib/matplotlib/toolkits/exceltools.py 2008-04-03 15:24:20 UTC (rev 5028)
@@ -5,7 +5,7 @@
import matplotlib.mlab as mlab
import matplotlib.toolkits.exceltools as exceltools
-
+
r = mlab.csv2rec('somefile.csv', checkrows=0)
formatd = dict(
@@ -107,6 +107,10 @@
else:
if mlab.safe_isnan(val):
ws.write(rownum, colnum+i, 'NaN')
+ elif mlab.safe_isinf(val):
+ if val<0: sign='-'
+ else: sign='+'
+ ws.write(rownum, colnum+i, '%sInf'%sign)
else:
ws.write(rownum, colnum+i, val, format.xlstyle)
rownum += 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-04-02 13:34:01
|
Revision: 5027
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5027&view=rev
Author: mmetz_bn
Date: 2008-04-02 06:33:21 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
added linestyle patch
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/cbook.py
trunk/matplotlib/lib/matplotlib/collections.py
trunk/matplotlib/lib/matplotlib/lines.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-03-27 14:42:26 UTC (rev 5026)
+++ trunk/matplotlib/CHANGELOG 2008-04-02 13:33:21 UTC (rev 5027)
@@ -1,3 +1,6 @@
+2008-04-02 Allow to use both linestyle definition arguments, '-' and
+ 'solid' etc. in plots/collections - MM
+
2008-03-27 Fix saving to Unicode filenames with Agg backend
(other backends appear to already work...)
(Thanks, Christopher Barker) - MGD
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2008-03-27 14:42:26 UTC (rev 5026)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-04-02 13:33:21 UTC (rev 5027)
@@ -1068,6 +1068,16 @@
return result
+
+# a dict to cross-map linestyle arguments
+_linestyles = [('-', 'solid'),
+ ('--', 'dashed'),
+ ('-.', 'dashdot'),
+ (':', 'dotted')]
+
+ls_mapper = dict(_linestyles)
+ls_mapper.update([(ls[1], ls[0]) for ls in _linestyles])
+
if __name__=='__main__':
assert( allequal([1,1,1]) )
assert(not allequal([1,1,0]) )
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-03-27 14:42:26 UTC (rev 5026)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-04-02 13:33:21 UTC (rev 5027)
@@ -228,14 +228,25 @@
ACCEPTS: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) ]
"""
try:
+ dashd = backend_bases.GraphicsContextBase.dashd
if cbook.is_string_like(ls):
- dashes = [backend_bases.GraphicsContextBase.dashd[ls]]
+ if dashd.has_key(ls):
+ dashes = [dashd[ls]]
+ elif cbook.ls_mapper.has_key(ls):
+ dashes = [dashd[cbook.ls_mapper[ls]]]
+ else:
+ raise ValueError()
elif cbook.iterable(ls):
try:
dashes = []
for x in ls:
if cbook.is_string_like(x):
- dashes.append(backend_bases.GraphicsContextBase.dashd[ls])
+ if dashd.has_key(x):
+ dashes.append(dashd[x])
+ elif cbook.ls_mapper.has_key(x):
+ dashes.append(dashd[cbook.ls_mapper[x]])
+ else:
+ raise ValueError()
elif cbook.iterator(x) and len(x) == 2:
dashes.append(x)
else:
Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py 2008-03-27 14:42:26 UTC (rev 5026)
+++ trunk/matplotlib/lib/matplotlib/lines.py 2008-04-02 13:33:21 UTC (rev 5027)
@@ -11,7 +11,7 @@
from matplotlib import verbose
import artist
from artist import Artist
-from cbook import iterable, is_string_like, is_numlike
+from cbook import iterable, is_string_like, is_numlike, ls_mapper
from colors import colorConverter
from path import Path
from transforms import Affine2D, Bbox, TransformedPath
@@ -598,7 +598,10 @@
ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
"""
if linestyle not in self._lineStyles:
- verbose.report('Unrecognized line style %s, %s' %
+ if ls_mapper.has_key(linestyle):
+ linestyle = ls_mapper[linestyle]
+ else:
+ verbose.report('Unrecognized line style %s, %s' %
(linestyle, type(linestyle)))
if linestyle in [' ','']:
linestyle = 'None'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-03-27 14:42:29
|
Revision: 5026
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5026&view=rev
Author: mdboom
Date: 2008-03-27 07:42:26 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
Merged revisions 5024-5025 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
........
r5025 | mdboom | 2008-03-27 10:26:19 -0400 (Thu, 27 Mar 2008) | 4 lines
Fix saving to Unicode filenames in Agg backend. Fix Qt and Qt4 GUI's
to support saving to Unicode filenames in file save dialogs. Wx, Gtk
and Tk GUIs already appear to work.
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
trunk/matplotlib/lib/matplotlib/backends/backend_qt.py
trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
trunk/matplotlib/src/_backend_agg.cpp
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5023
+ /branches/v0_91_maint:1-5025
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-03-27 14:26:19 UTC (rev 5025)
+++ trunk/matplotlib/CHANGELOG 2008-03-27 14:42:26 UTC (rev 5026)
@@ -1,3 +1,7 @@
+2008-03-27 Fix saving to Unicode filenames with Agg backend
+ (other backends appear to already work...)
+ (Thanks, Christopher Barker) - MGD
+
2008-03-26 Fix SVG backend bug that prevents copying and pasting in
Inkscape (thanks Kaushik Ghose) - MGD
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-03-27 14:26:19 UTC (rev 5025)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-03-27 14:42:26 UTC (rev 5026)
@@ -286,19 +286,23 @@
def get_default_filetype(self):
return 'png'
- def print_raw(self, filename, *args, **kwargs):
+ def print_raw(self, filename_or_obj, *args, **kwargs):
FigureCanvasAgg.draw(self)
+ renderer = self.get_renderer()
original_dpi = renderer.dpi
renderer.dpi = self.figure.dpi
- renderer._renderer.write_rgba(str(filename))
+ if type(filename_or_obj) in (str, unicode):
+ filename_or_obj = open(filename_or_obj, 'w')
+ renderer._renderer.write_rgba(filename_or_obj)
renderer.dpi = original_dpi
print_rgba = print_raw
- def print_png(self, filename, *args, **kwargs):
+ def print_png(self, filename_or_obj, *args, **kwargs):
FigureCanvasAgg.draw(self)
renderer = self.get_renderer()
original_dpi = renderer.dpi
renderer.dpi = self.figure.dpi
- filename = str(filename) # until we figure out unicode handling
- renderer._renderer.write_png(filename, self.figure.dpi)
+ if type(filename_or_obj) in (str, unicode):
+ filename_or_obj = open(filename_or_obj, 'w')
+ self.get_renderer()._renderer.write_png(filename_or_obj, self.figure.dpi)
renderer.dpi = original_dpi
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-03-27 14:26:19 UTC (rev 5025)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-03-27 14:42:26 UTC (rev 5026)
@@ -427,7 +427,7 @@
selectedFilter)
if fname:
try:
- self.canvas.print_figure( fname.latin1() )
+ self.canvas.print_figure( unicode(fname) )
except Exception, e:
qt.QMessageBox.critical(
self, "Error saving file", str(e),
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-03-27 14:26:19 UTC (rev 5025)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-03-27 14:42:26 UTC (rev 5026)
@@ -376,7 +376,7 @@
self, "Choose a filename to save to", start, filters, selectedFilter)
if fname:
try:
- self.canvas.print_figure( str(fname.toLatin1()) )
+ self.canvas.print_figure( unicode(fname) )
except Exception, e:
QtGui.QMessageBox.critical(
self, "Error saving file", str(e),
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-03-27 14:26:19 UTC (rev 5025)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-03-27 14:42:26 UTC (rev 5026)
@@ -1286,12 +1286,33 @@
_VERBOSE("RendererAgg::write_rgba");
args.verify_length(1);
- std::string fname = Py::String(args[0]);
- std::ofstream of2( fname.c_str(), std::ios::binary|std::ios::out);
- for (size_t i=0; i<NUMBYTES; i++) {
- of2.write((char*)&(pixBuffer[i]), sizeof(char));
+ FILE *fp = NULL;
+ bool close_file = false;
+ Py::Object py_fileobj = Py::Object(args[0]);
+ if (py_fileobj.isString()) {
+ std::string fileName = Py::String(py_fileobj);
+ const char *file_name = fileName.c_str();
+ if ((fp = fopen(file_name, "wb")) == NULL)
+ throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
+ fwrite(pixBuffer, 1, NUMBYTES, fp);
+ close_file = true;
+ fclose(fp);
+ } else if (PyFile_CheckExact(py_fileobj.ptr())) {
+ fp = PyFile_AsFile(py_fileobj.ptr());
+ fwrite(pixBuffer, 1, NUMBYTES, fp);
+ } else {
+ PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
+ if (!(write_method && PyCallable_Check(write_method))) {
+ Py_XDECREF(write_method);
+ throw Py::TypeError("Object does not appear to be a 8-bit string path or a Python file-like object");
+ }
+
+ PyObject_CallFunction(write_method, "s#", pixBuffer, NUMBYTES);
+
+ Py_XDECREF(write_method);
}
+
return Py::Object();
}
@@ -1326,18 +1347,22 @@
args.verify_length(1, 2);
FILE *fp = NULL;
+ bool close_file = false;
Py::Object py_fileobj = Py::Object(args[0]);
if (py_fileobj.isString()) {
std::string fileName = Py::String(py_fileobj);
const char *file_name = fileName.c_str();
if ((fp = fopen(file_name, "wb")) == NULL)
throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
+ close_file = true;
+ } else if (PyFile_CheckExact(py_fileobj.ptr())) {
+ fp = PyFile_AsFile(py_fileobj.ptr());
}
else {
PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
if (!(write_method && PyCallable_Check(write_method))) {
Py_XDECREF(write_method);
- throw Py::TypeError("Object does not appear to be a path or a Python file-like object");
+ throw Py::TypeError("Object does not appear to be a 8-bit string path or a Python file-like object");
}
Py_XDECREF(write_method);
}
@@ -1406,7 +1431,7 @@
*/
} catch (...) {
- if (fp) fclose(fp);
+ if (fp && close_file) fclose(fp);
delete [] row_pointers;
if (png_ptr && info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
throw;
@@ -1414,7 +1439,7 @@
png_destroy_write_struct(&png_ptr, &info_ptr);
delete [] row_pointers;
- if (fp) fclose(fp);
+ if (fp && close_file) fclose(fp);
return Py::Object();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-03-27 14:26:22
|
Revision: 5025
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5025&view=rev
Author: mdboom
Date: 2008-03-27 07:26:19 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
Fix saving to Unicode filenames in Agg backend. Fix Qt and Qt4 GUI's
to support saving to Unicode filenames in file save dialogs. Wx, Gtk
and Tk GUIs already appear to work.
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/backends/backend_agg.py
branches/v0_91_maint/lib/matplotlib/backends/backend_qt.py
branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py
branches/v0_91_maint/src/_backend_agg.cpp
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-03-26 14:43:20 UTC (rev 5024)
+++ branches/v0_91_maint/CHANGELOG 2008-03-27 14:26:19 UTC (rev 5025)
@@ -1,3 +1,7 @@
+2008-03-27 Fix saving to Unicode filenames with Agg backend
+ (other backends appear to already work...)
+ (Thanks, Christopher Barker) - MGD
+
2008-03-26 Fix SVG backend bug that prevents copying and pasting in
Inkscape (thanks Kaushik Ghose) - MGD
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_agg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_agg.py 2008-03-26 14:43:20 UTC (rev 5024)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_agg.py 2008-03-27 14:26:19 UTC (rev 5025)
@@ -387,13 +387,17 @@
def get_default_filetype(self):
return 'png'
- def print_raw(self, filename, *args, **kwargs):
+ def print_raw(self, filename_or_obj, *args, **kwargs):
self.draw()
- self.get_renderer()._renderer.write_rgba(str(filename))
+ if type(filename_or_obj) in (str, unicode):
+ filename_or_obj = open(filename_or_obj, 'w')
+ self.get_renderer()._renderer.write_rgba(filename_or_obj)
print_rgba = print_raw
- def print_png(self, filename, *args, **kwargs):
+ def print_png(self, filename_or_obj, *args, **kwargs):
self.draw()
- filename = str(filename) # until we figure out unicode handling
- self.get_renderer()._renderer.write_png(filename, self.figure.dpi.get())
+ if type(filename_or_obj) in (str, unicode):
+ filename_or_obj = open(filename_or_obj, 'w')
+ self.get_renderer()._renderer.write_png(filename_or_obj,
+ self.figure.dpi.get())
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_qt.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_qt.py 2008-03-26 14:43:20 UTC (rev 5024)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_qt.py 2008-03-27 14:26:19 UTC (rev 5025)
@@ -425,7 +425,7 @@
selectedFilter)
if fname:
try:
- self.canvas.print_figure( fname.latin1() )
+ self.canvas.print_figure( unicode(fname) )
except Exception, e:
qt.QMessageBox.critical(
self, "Error saving file", str(e),
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py 2008-03-26 14:43:20 UTC (rev 5024)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py 2008-03-27 14:26:19 UTC (rev 5025)
@@ -425,12 +425,12 @@
selectedFilter = filter
filters.append(filter)
filters = ';;'.join(filters)
-
+
fname = QtGui.QFileDialog.getSaveFileName(
self, "Choose a filename to save to", start, filters, selectedFilter)
if fname:
try:
- self.canvas.print_figure( str(fname.toLatin1()) )
+ self.canvas.print_figure( unicode(fname) )
except Exception, e:
QtGui.QMessageBox.critical(
self, "Error saving file", str(e),
Modified: branches/v0_91_maint/src/_backend_agg.cpp
===================================================================
--- branches/v0_91_maint/src/_backend_agg.cpp 2008-03-26 14:43:20 UTC (rev 5024)
+++ branches/v0_91_maint/src/_backend_agg.cpp 2008-03-27 14:26:19 UTC (rev 5025)
@@ -2247,14 +2247,34 @@
_VERBOSE("RendererAgg::write_rgba");
args.verify_length(1);
- std::string fname = Py::String( args[0]);
- std::ofstream of2( fname.c_str(), std::ios::binary|std::ios::out);
- for (size_t i=0; i<NUMBYTES; i++) {
- of2.write((char*)&(pixBuffer[i]), sizeof(char));
+ FILE *fp = NULL;
+ bool close_file = false;
+ Py::Object py_fileobj = Py::Object(args[0]);
+ if (py_fileobj.isString()) {
+ std::string fileName = Py::String(py_fileobj);
+ const char *file_name = fileName.c_str();
+ if ((fp = fopen(file_name, "wb")) == NULL)
+ throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
+ fwrite(pixBuffer, 1, NUMBYTES, fp);
+ close_file = true;
+ fclose(fp);
+ } else if (PyFile_CheckExact(py_fileobj.ptr())) {
+ fp = PyFile_AsFile(py_fileobj.ptr());
+ fwrite(pixBuffer, 1, NUMBYTES, fp);
+ } else {
+ PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
+ if (!(write_method && PyCallable_Check(write_method))) {
+ Py_XDECREF(write_method);
+ throw Py::TypeError("Object does not appear to be a 8-bit string path or a Python file-like object");
+ }
+
+ PyObject_CallFunction(write_method, "s#", pixBuffer, NUMBYTES);
+
+ Py_XDECREF(write_method);
}
+
return Py::Object();
-
}
static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) {
@@ -2288,18 +2308,22 @@
args.verify_length(1, 2);
FILE *fp = NULL;
+ bool close_file = false;
Py::Object py_fileobj = Py::Object(args[0]);
if (py_fileobj.isString()) {
std::string fileName = Py::String(py_fileobj);
const char *file_name = fileName.c_str();
if ((fp = fopen(file_name, "wb")) == NULL)
throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
+ close_file = true;
+ } else if (PyFile_CheckExact(py_fileobj.ptr())) {
+ fp = PyFile_AsFile(py_fileobj.ptr());
}
else {
PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
if (!(write_method && PyCallable_Check(write_method))) {
Py_XDECREF(write_method);
- throw Py::TypeError("Object does not appear to be a path or a Python file-like object");
+ throw Py::TypeError("Object does not appear to be a 8-bit string path or a Python file-like object");
}
Py_XDECREF(write_method);
}
@@ -2368,7 +2392,7 @@
*/
} catch (...) {
- if (fp) fclose(fp);
+ if (fp && close_file) fclose(fp);
delete [] row_pointers;
if (png_ptr && info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
throw;
@@ -2376,7 +2400,7 @@
png_destroy_write_struct(&png_ptr, &info_ptr);
delete [] row_pointers;
- if (fp) fclose(fp);
+ if (fp && close_file) fclose(fp);
return Py::Object();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-03-26 15:04:47
|
Revision: 5022
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5022&view=rev
Author: mdboom
Date: 2008-03-26 07:33:35 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
Change character ids so they are a hash on the path data itself. (To
fix Kaushik Ghose's copy-and-paste in Inkscape bug).
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-03-26 14:30:18 UTC (rev 5021)
+++ branches/v0_91_maint/CHANGELOG 2008-03-26 14:33:35 UTC (rev 5022)
@@ -1,3 +1,6 @@
+2008-03-26 Fix SVG backend bug that prevents copying and pasting in
+ Inkscape (thanks Kaushik Ghose) - MGD
+
2008-03-23 Fix a pdf backend bug which sometimes caused the outermost
gsave to not be balanced with a grestore. - JKS
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-03-26 14:43:33
|
Revision: 5024
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5024&view=rev
Author: mdboom
Date: 2008-03-26 07:43:20 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
Merged revisions 5012-5017,5019-5023 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
........
r5013 | mmetz_bn | 2008-03-21 13:19:37 -0400 (Fri, 21 Mar 2008) | 1 line
Bugfix in ContourSet._process_linestyles
........
r5021 | mdboom | 2008-03-26 10:30:18 -0400 (Wed, 26 Mar 2008) | 3 lines
Change character ids so they are a hash on the path data itself. (To
fix Kaushik Ghose's copy-and-paste in Inkscape bug).
........
r5022 | mdboom | 2008-03-26 10:33:35 -0400 (Wed, 26 Mar 2008) | 3 lines
Change character ids so they are a hash on the path data itself. (To
fix Kaushik Ghose's copy-and-paste in Inkscape bug).
........
r5023 | mdboom | 2008-03-26 10:35:50 -0400 (Wed, 26 Mar 2008) | 2 lines
Oops in last commit.
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5011,5018
+ /branches/v0_91_maint:1-5023
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-03-26 14:35:50 UTC (rev 5023)
+++ trunk/matplotlib/CHANGELOG 2008-03-26 14:43:20 UTC (rev 5024)
@@ -1,3 +1,6 @@
+2008-03-26 Fix SVG backend bug that prevents copying and pasting in
+ Inkscape (thanks Kaushik Ghose) - MGD
+
2008-03-24 Removed an unnecessary call to draw() in the backend_qt*
mouseReleaseEvent. Thanks to Ted Drain - DSD
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-03-26 14:35:50 UTC (rev 5023)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-03-26 14:43:20 UTC (rev 5024)
@@ -1,6 +1,6 @@
from __future__ import division
-import os, codecs, base64, tempfile, urllib, gzip
+import os, codecs, base64, tempfile, urllib, gzip, md5
from matplotlib import verbose, __version__, rcParams
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
@@ -125,7 +125,7 @@
id = self._clipd.get(path)
if id is None:
- id = 'p%x' % len(self._clipd)
+ id = 'p%s' % md5.new(path).hexdigest()
self._svgwriter.write('<defs>\n <clipPath id="%s">\n' % id)
self._svgwriter.write(path)
self._svgwriter.write('\n </clipPath>\n</defs>')
@@ -189,7 +189,7 @@
key = self._convert_path(marker_path, marker_trans + Affine2D().scale(1.0, -1.0))
name = self._markers.get(key)
if name is None:
- name = 'm%x' % len(self._markers)
+ name = 'm%s' % md5.new(key).hexdigest()
write('<defs><path id="%s" d="%s"/></defs>\n' % (name, key))
self._markers[key] = name
@@ -209,9 +209,10 @@
write('<defs>\n')
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
master_transform, paths, all_transforms)):
- name = 'coll%x_%x' % (self._path_collection_id, i)
transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0)
d = self._convert_path(path, transform)
+ name = 'coll%x_%x_%s' % (self._path_collection_id, i,
+ md5.new(d).hexdigest())
write('<path id="%s" d="%s"/>\n' % (name, d))
path_codes.append(name)
write('</defs>\n')
@@ -398,8 +399,9 @@
if step[0] != 4:
currx, curry = step[-2], -step[-1]
- char_num = 'c%x' % len(self._char_defs)
- path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
+ path_data = ''.join(path_data)
+ char_num = 'c_%s' % md5.new(path_data).hexdigest()
+ path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
self._char_defs[char_id] = char_num
return path_element
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-03-26 14:37:32
|
Revision: 5023
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5023&view=rev
Author: mdboom
Date: 2008-03-26 07:35:50 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
Oops in last commit.
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-03-26 14:33:35 UTC (rev 5022)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-03-26 14:35:50 UTC (rev 5023)
@@ -389,7 +389,7 @@
if step[0] != 4:
currx, curry = step[-2], -step[-1]
path_data = ''.join(path_data)
- char_num = 'c_%x' % len(self._char_defs) # md5.new(path_data).hexdigest()
+ char_num = 'c_%s' % md5.new(path_data).hexdigest()
path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
self._char_defs[char_id] = char_num
return path_element
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-03-26 14:30:27
|
Revision: 5021
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5021&view=rev
Author: mdboom
Date: 2008-03-26 07:30:18 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
Change character ids so they are a hash on the path data itself. (To
fix Kaushik Ghose's copy-and-paste in Inkscape bug).
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-03-24 12:58:47 UTC (rev 5020)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-03-26 14:30:18 UTC (rev 5021)
@@ -1,6 +1,6 @@
from __future__ import division
-import os, codecs, base64, tempfile, urllib, gzip
+import os, codecs, base64, tempfile, urllib, gzip, md5
from matplotlib import agg
from matplotlib import verbose, __version__, rcParams
@@ -388,8 +388,9 @@
if step[0] != 4:
currx, curry = step[-2], -step[-1]
- char_num = 'c_%x' % len(self._char_defs)
- path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
+ path_data = ''.join(path_data)
+ char_num = 'c_%x' % len(self._char_defs) # md5.new(path_data).hexdigest()
+ path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
self._char_defs[char_id] = char_num
return path_element
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-03-24 12:58:53
|
Revision: 5020
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5020&view=rev
Author: dsdale
Date: 2008-03-24 05:58:47 -0700 (Mon, 24 Mar 2008)
Log Message:
-----------
removed an unnecessary call to draw in the qt backends mouseReleaseEvent
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_qt.py
trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-03-23 17:47:51 UTC (rev 5019)
+++ trunk/matplotlib/CHANGELOG 2008-03-24 12:58:47 UTC (rev 5020)
@@ -1,3 +1,6 @@
+2008-03-24 Removed an unnecessary call to draw() in the backend_qt*
+ mouseReleaseEvent. Thanks to Ted Drain - DSD
+
2008-03-23 Fix a pdf backend bug which sometimes caused the outermost
gsave to not be balanced with a grestore. - JKS
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-03-23 17:47:51 UTC (rev 5019)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-03-24 12:58:47 UTC (rev 5020)
@@ -121,7 +121,6 @@
button = self.buttond[event.button()]
FigureCanvasBase.button_release_event( self, x, y, button )
if DEBUG: print 'button released'
- self.draw()
def keyPressEvent( self, event ):
key = self._get_key( event )
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-03-23 17:47:51 UTC (rev 5019)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-03-24 12:58:47 UTC (rev 5020)
@@ -120,7 +120,6 @@
button = self.buttond[event.button()]
FigureCanvasBase.button_release_event( self, x, y, button )
if DEBUG: print 'button released'
- self.draw()
def keyPressEvent( self, event ):
key = self._get_key( event )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2008-03-23 17:47:54
|
Revision: 5019
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5019&view=rev
Author: jouni
Date: 2008-03-23 10:47:51 -0700 (Sun, 23 Mar 2008)
Log Message:
-----------
Merged revisions 5018 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
........
r5018 | jouni | 2008-03-23 19:44:11 +0200 (Sun, 23 Mar 2008) | 3 lines
Fix a pdf backend bug which sometimes caused the outermost
gsave to not be balanced with a grestore.
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5011
+ /branches/v0_91_maint:1-5011,5018
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-03-23 17:44:11 UTC (rev 5018)
+++ trunk/matplotlib/CHANGELOG 2008-03-23 17:47:51 UTC (rev 5019)
@@ -1,3 +1,6 @@
+2008-03-23 Fix a pdf backend bug which sometimes caused the outermost
+ gsave to not be balanced with a grestore. - JKS
+
2008-03-20 Fixed a minor bug in ContourSet._process_linestyles when
len(linestyles)==Nlev - MM
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-03-23 17:44:11 UTC (rev 5018)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-03-23 17:47:51 UTC (rev 5019)
@@ -1174,7 +1174,7 @@
self.tex_font_map = None
def finalize(self):
- self.gc.finalize()
+ self.file.output(*self.gc.finalize())
def check_gc(self, gc, fillcolor=None):
orig_fill = gc._fillcolor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2008-03-23 17:44:19
|
Revision: 5018
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5018&view=rev
Author: jouni
Date: 2008-03-23 10:44:11 -0700 (Sun, 23 Mar 2008)
Log Message:
-----------
Fix a pdf backend bug which sometimes caused the outermost
gsave to not be balanced with a grestore.
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/backends/backend_pdf.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-03-21 19:52:46 UTC (rev 5017)
+++ branches/v0_91_maint/CHANGELOG 2008-03-23 17:44:11 UTC (rev 5018)
@@ -1,3 +1,6 @@
+2008-03-23 Fix a pdf backend bug which sometimes caused the outermost
+ gsave to not be balanced with a grestore. - JKS
+
2008-02-29 Fix class Wx toolbar pan and zoom functions (Thanks Jeff
Peery) - MGD
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_pdf.py 2008-03-21 19:52:46 UTC (rev 5017)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_pdf.py 2008-03-23 17:44:11 UTC (rev 5018)
@@ -1159,7 +1159,7 @@
self.tex_font_map = None
def finalize(self):
- self.gc.finalize()
+ self.file.output(*self.gc.finalize())
def check_gc(self, gc, fillcolor=None):
orig_fill = gc._fillcolor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-03-21 19:52:48
|
Revision: 5017
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5017&view=rev
Author: jdh2358
Date: 2008-03-21 12:52:46 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
committed mark hammiltons cutils fix
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/config/cutils.py
Modified: trunk/matplotlib/lib/matplotlib/config/cutils.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/config/cutils.py 2008-03-21 17:57:47 UTC (rev 5016)
+++ trunk/matplotlib/lib/matplotlib/config/cutils.py 2008-03-21 19:52:46 UTC (rev 5017)
@@ -79,7 +79,7 @@
raise RuntimeError("""\
'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir.
You can also set environment variable MPLCONFIGDIR to any writable directory
-where you want matplotlib data stored """%h)
+where you want matplotlib data stored """%(p,h))
else:
if not is_writable_dir(h):
raise RuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-03-21 17:57:49
|
Revision: 5016
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5016&view=rev
Author: jdh2358
Date: 2008-03-21 10:57:47 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
more cleanup
Modified Paths:
--------------
trunk/matplotlib/doc/make.py
Modified: trunk/matplotlib/doc/make.py
===================================================================
--- trunk/matplotlib/doc/make.py 2008-03-21 17:54:20 UTC (rev 5015)
+++ trunk/matplotlib/doc/make.py 2008-03-21 17:57:47 UTC (rev 5016)
@@ -34,7 +34,7 @@
os.system('pdflatex event_handling_tut.tex')
def clean():
- patterns = ['#*', '*~', '*.tex', '*.log', '*.out', '*.aux']
+ patterns = ['#*', '*~', '*.tex', '*.log', '*.out', '*.aux', '*.pdf']
for pattern in patterns:
for fname in glob.glob(pattern):
os.remove(fname)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-03-21 17:54:36
|
Revision: 5015
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5015&view=rev
Author: jdh2358
Date: 2008-03-21 10:54:20 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
added fig_x
Modified Paths:
--------------
trunk/matplotlib/doc/figures/make.py
Added Paths:
-----------
trunk/matplotlib/doc/figures/fig_x.py
Added: trunk/matplotlib/doc/figures/fig_x.py
===================================================================
--- trunk/matplotlib/doc/figures/fig_x.py (rev 0)
+++ trunk/matplotlib/doc/figures/fig_x.py 2008-03-21 17:54:20 UTC (rev 5015)
@@ -0,0 +1,13 @@
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.lines as lines
+fig = plt.figure()
+
+l1 = lines.Line2D([0, 1], [0, 1], transform=fig.transFigure, figure=fig)
+
+l2 = lines.Line2D([0, 1], [1, 0], transform=fig.transFigure, figure=fig)
+
+fig.lines.extend([l1, l2])
+
+fig.savefig('fig_x')
+plt.show()
Modified: trunk/matplotlib/doc/figures/make.py
===================================================================
--- trunk/matplotlib/doc/figures/make.py 2008-03-21 17:51:06 UTC (rev 5014)
+++ trunk/matplotlib/doc/figures/make.py 2008-03-21 17:54:20 UTC (rev 5015)
@@ -8,6 +8,7 @@
import dollar_ticks
import fig_axes_customize_simple
import fig_axes_labels_simple
+ import fig_x
print 'all figures made'
for fname in glob.glob('*.pyc'):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-03-21 17:51:13
|
Revision: 5014
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5014&view=rev
Author: jdh2358
Date: 2008-03-21 10:51:06 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
added api and event tutorials
Added Paths:
-----------
trunk/matplotlib/doc/artist_api_tut.txt
trunk/matplotlib/doc/event_handling_tut.txt
trunk/matplotlib/doc/figures/
trunk/matplotlib/doc/figures/dollar_ticks.py
trunk/matplotlib/doc/figures/fig_axes_customize_simple.py
trunk/matplotlib/doc/figures/fig_axes_labels_simple.py
trunk/matplotlib/doc/figures/make.py
trunk/matplotlib/doc/make.py
Added: trunk/matplotlib/doc/artist_api_tut.txt
===================================================================
--- trunk/matplotlib/doc/artist_api_tut.txt (rev 0)
+++ trunk/matplotlib/doc/artist_api_tut.txt 2008-03-21 17:51:06 UTC (rev 5014)
@@ -0,0 +1,597 @@
+The matplotlib Artist API tutorial
+==================================
+
+There are three layers to the matplotlib API. The FigureCanvas is the
+area onto which the figure is drawn, the Renderer is the object which
+knows how to draw on the FigureCanvas, and the Artist is the object
+that knows how to use a renderer to paint onto the canvas. The
+FigureCanvas and Renderer handle all the details of talking to user
+interface toolkits like wxpython or drawing languages like postscript,
+and the Artist handles all the high level constructs like
+representing and laying out the figure, text, and lines. The typical
+user will spend 95% of his time working with the Artists.
+
+There are two types Artists: primitives and containers. The
+primitives represent the standard graphical objects we want to paint
+onto our canvas: Line2D, Rectangle, Text, AxesImage, etc, and the
+containers are places to put them (Axis, Axes and Figure). The
+standard use is to create a Figure instance, use the Figure to create
+one or more Axes or Subplot instances, and use the Axes instance
+helper methods to create the primitives. In the example below, we
+create a Figure instance using pyplot.figure, which is a convenience
+method for instantiating Figure instances and connecting them with
+your user interface or drawing toolkit FigureCanvas. As we will
+discuss below, this is not necessary, and you can work directly with
+postscript, pdf gtk, or wxpython FigureCanvas es, instantiate your
+Figures directly and connect them yourselves, but since we are
+focusing here on the Artist API we'll let pyplot handle some of those
+details for us::
+
+ import matplotlib.pyplot as plt
+ fig = plt.figure()
+ ax = fig.add_subplot(2,1,1) # two rows, one column, first plot
+
+The Axes is probably the most important class in the matplotlib API,
+and the one you will be working with most of the time. This is
+because the Axes is the plotting area into which most of the objects
+go, and the Axes has many special helper methods (ax.plot, ax.text,
+ax.hist, ax.imshow) to create the most common graphics primitives
+(Line2D, Text, Rectangle, Image, respectively). These helper methods
+will take your data (eg numpy arrays and strings) create primitive
+Artist instances as needed (eg Line2D), add them to the relevant
+containers, and draw them when requested. Most of you are probably
+familiar with the Subplot, which is just a special case of an Axes
+that lives on a regular rows by columns grid of Subplot instances. If
+you want to create an Axes at an arbitrary location, simply use the
+add_axes method which takes a list of [left, bottom, width, height]
+values in 0-1 relative figure coordinates::
+
+ ax2 = fig.add_axes([0.15, 0.1, 0.7, 0.3])
+
+Continuing with our example::
+
+ import numpy as np
+ t = np.arange(0.0, 1.0, 0.01)
+ s = np.sin(2*np.pi*t)
+ line, = ax1.plot(t, s, color='blue', lw=2)
+
+In this example, ax is the Axes instance created by the
+fig.add_subplot call above (remember Subplot is just a subclass of
+Axes) and when you call ax.plot, it creates a Line2D instance and adds
+it the the Axes.lines list. In the interactive ipython session below,
+you can see that Axes.lines list is length one and contains the same
+line that was returned by the "line, ax.plot(x, y, 'o')" call::
+
+ In [101]: ax.lines[0]
+ Out[101]: <matplotlib.lines.Line2D instance at 0x19a95710>
+
+ In [102]: line
+ Out[102]: <matplotlib.lines.Line2D instance at 0x19a95710>
+
+If you make subsequent calls to ax.plot (and the hold state is "on"
+which is the default) then additional lines will be added to the list.
+You can remove lines later simply by calling the list methods; either
+of these will work::
+
+ del ax.lines[0]
+ ax.lines.remove(line) # one or the other, not both!
+
+The Axes also has helper methods to configure and decorate the xaxis
+and yaxis tick, ticklabels and axis labels::
+
+ xtext = ax.set_xlabel('my xdata') # returns a Text instance
+ ytext = ax.set_ylabel('my xdata')
+
+When you call ax.set_xlabel, it passes the information on the Text
+instance of the XAxis. Each Axes instance contains an xaxis and a
+yaxis instance, which handle the layout and drawing of the ticks, tick
+labels and axis labels.
+
+Here are the most important matplotlib modules that contain the
+classes referenced above
+
+=============== ==================
+Artist Module
+=============== ==================
+Artist matplotlib.artist
+Rectangle matplotlib.patches
+Line2D matplotlib.lines
+Axes matplotlib.axes
+XAxis and YAxis matplotlib.axis
+Figure matplotlib.figure
+Text matplotlib.text
+=============== ==================
+
+Try creating the figure below
+
+.. image:: figures/fig_axes_labels_simple.png
+ :scale: 75
+
+Customizing your objects
+========================
+
+Every element in the figure is represented by a matplotlib Artist, and
+each has an extensive list of properties to configure its appearance.
+The figure itself contains a Rectangle exactly the size of the figure,
+which you can use to set the background color and transparency of the
+figures. Likewise, each Axes bounding box (the standard white box
+with black edges in the typical matplotlib plot, has a Rectangle
+instance that determines the color, transparency, and other properties
+of the Axes. These instances are stored as member variables
+Figure.figurePatch and Axes.axesPatch ("Patch" is a name inherited
+from Matlab, and is a 2D "patch" of color on the figure, eg
+rectangles, circles and polygons). Every matplotlib Artist has the
+following properties
+
+========== ======================================================================
+Property Description
+========== ======================================================================
+alpha The transparency - a scalar from 0-1
+animated A boolean that is used to facilitate animated drawing
+axes The axes that the Artist lives in, possibly None
+clip_box The bounding box that clips the Artist
+clip_on Whether clipping is enabled
+clip_path The path the artist is clipped to
+contains A picking function to test whether the artist contains the pick point
+figure The figure instance the aritst lives in, possibly None
+label A text label (eg for auto-labeling)
+picker A python object that controls object picking
+transform The transformation
+visible A boolean whether the artist should be drawn
+zorder A number which determines the drawing order
+========== ======================================================================
+
+Each of the properties is accessed with an old-fashioned setter or
+getter (yes we know this irritates pythonistas and we plan to support
+direct access via properties or traits but it hasn't been done yet).
+For example, to multiply the current alpha by a half::
+
+ a = o.get_alpha()
+ o.set_alpha(0.5*a)
+
+If you want to set a number of properties at once, you can also use
+the "set" method with keyword arguments. For example::
+
+ o.set(alpha=0.5, zorder=2)
+
+If you are working interactively at the python shell, a handy way to
+inspect the artist properties is to use the matplotlib.artist.getp
+method, which lists the properties and their values (simply "getp") in
+pylab. This works for classes derived from Artist as well, eg Figure
+and Rectangle. Here are the Figure rectangle properties mentioned above::
+
+
+ In [149]: matplotlib.artist.getp(fig.figurePatch)
+ alpha = 1.0
+ animated = False
+ antialiased or aa = True
+ axes = None
+ clip_box = None
+ clip_on = False
+ clip_path = None
+ contains = None
+ edgecolor or ec = w
+ facecolor or fc = 0.75
+ figure = Figure(8.125x6.125)
+ fill = 1
+ hatch = None
+ height = 1
+ label =
+ linewidth or lw = 1.0
+ picker = None
+ transform = <Affine object at 0x134cca84>
+ verts = ((0, 0), (0, 1), (1, 1), (1, 0))
+ visible = True
+ width = 1
+ window_extent = <Bbox object at 0x134acbcc>
+ x = 0
+ y = 0
+ zorder = 1
+
+The docstrings for all of the classes also contain the artist
+properties, so you can consult the interactive "help", the online html
+docs at http://matplotlib.sourceforge.net/classdocs.html or PDF documentation
+at http://matplotlib.sourceforge.net/api.pdf for a listing of
+properties for a give object.
+
+Getting at the objects to customize them
+========================================
+
+Now that we know how to inspect set the properties of a given
+object we want to configure, we need to now how to get at that
+object. As mentioned in the introduction, there are two kinds of
+objects: primitives and containers. The primitives are usually the
+things you want to configure (the font of a Text instance, the width
+of a Line2D) although the containers also have some properties as
+well -- for example the Axes Artist is a container that contains many
+of the primitives in your plot, but it also has properties like the
+xscale to control whether the xaxis is 'linear' or 'log'. In this
+section we'll review where the various container objects store the
+Artists that you want to get at.
+
+The Figure container
+--------------------
+
+The top level container Artist is the matplotlib.figure.Figure, and it
+contains everything in the figure. The background of the figure is a
+Rectangle which is stored in fig.figurePatch (where fig is your Figure
+instance). As you add subplots (fig.add_subplot) and axes
+(ax.add_axes)to the figure these will be appended to the fig.axes
+list. These are also returned by the methods that create them::
+
+ In [156]: fig = plt.figure()
+
+ In [157]: ax1 = fig.add_subplot(211)
+
+ In [158]: ax2 = fig.add_axes([0.1, 0.1, 0.7, 0.3])
+
+ In [159]: ax1
+ Out[159]: <matplotlib.axes.Subplot instance at 0xd54b26c>
+
+ In [160]: print fig.axes
+ [<matplotlib.axes.Subplot instance at 0xd54b26c>, <matplotlib.axes.Axes instance at 0xd3f0b2c>]
+
+
+Because the figure maintains the concept of the "current axes" (see
+Figure.gca and Figure.sca) to support the pylab/pyplot state machine,
+you should not insert or remove axes directly from the axes list, but
+rather use the Figure.add_axes and Figure.add_subplot method to
+insert, and the Figure.delaxes methods to delete. You are free
+however, to iterate over the list of axes or index into it to get
+access to Axes instances you want to customize. Here is an example
+which turns all the axes grids on::
+
+ for ax in fig.axes:
+ ax.grid(True)
+
+
+The figure also has its own text, lines, patches and images, which you
+can use to add primitives directly. The default coordinate system for
+the Figure will simply be in pixels (which is not usually what you
+want) but you can control this by setting the transform property of
+the Artist you are adding to the figure. More useful is "figure
+coordinates" where 0,0 is the bottom, left of the figure and 1,1 is
+the top, right of the figure which you can obtain by setting the
+Artist transform to fig.transFigure::
+
+ In [191]: fig = plt.figure()
+
+ In [192]: l1 = matplotlib.lines.Line2D([0, 1], [0, 1], transform=fig.transFigure, figure=fig)
+
+ In [193]: l2 = matplotlib.lines.Line2D([0, 1], [1, 0], transform=fig.transFigure, figure=fig)
+
+ In [194]: fig.lines.extend([l1, l2])
+
+ In [195]: fig.canvas.draw()
+
+.. image:: figures/fig_x.png
+ :scale: 75
+
+
+Here is a summary of the Artists the figure contains
+
+================ ===============================================================
+Figure attribute Description
+================ ===============================================================
+axes A list of Axes instances (includes Subplot)
+figurePatch The Rectangle background
+images A list of FigureImages patches - useful for raw pixel display
+legends A list of Figure Legend instances (different from Axes.legends)
+lines A list of Figure Line2D instances (rarely used, see Axes.lines)
+patches A list of Figure patches (rarely used, see Axes.patches)
+texts A list Figure Text instances
+================ ===============================================================
+
+
+The Axes container
+------------------
+
+The matplotlib.axes.Axes is the center of the matplotlib universe --
+it contains the vast majority of all the Artists used in a figure with
+many helper methods to create and these Artists to itself, as well as
+helper methods to access and customize the Artists it contains. Like
+the Figure, it contains a Patch ax.axesPatch which is Rectangle for
+Cartesian coordinates and a Circle for polar coordinates; this patch
+determines the shape, background and border of the plotting region::
+
+ ax = fig.add_subplot(111)
+ rect = ax.axesPatch # a Rectangle instance
+ rect.set_facecolor('green')
+
+When you call a plotting method, eg the canonical "ax.plot" and pass
+in arrays or list of values, the method will a matplotlib.lines.Line2D
+instance, update the line with all the Line2D properties passed as
+keyword arguments, add the line to the Axes.lines container, and
+returns it to you::
+
+ In [213]: x, y = np.random.rand(2, 100)
+
+ In [214]: line, = ax.plot(x, y, '-', color='blue', linewidth=2)
+
+ax.plot returns a list of lines because you can pass in multiple x, y
+pairs to plot, and we are unpacking the first element of the length
+one list into the line variable. The line has been added to the
+ax.lines list::
+
+
+ In [229]: print ax.lines
+ [<matplotlib.lines.Line2D instance at 0xd378b0c>]
+
+Similarly, methods that create patches, like ax.bar creates a list of
+rectangles, will add the patches to the ax.patches list::
+
+ In [233]: n, bins, rectangles = ax.hist(np.random.randn(1000), 50, facecolor='yellow')
+
+ In [234]: rectangles
+ Out[234]: <a list of 50 Patch objects>
+
+ In [235]: print len(ax.patches)
+
+You should not add objects directly to the ax.lines or ax.patches
+unless you know exactly what you are doing, because the Axes needs to
+do a few things when it creates and adds an object. It sets the figure
+and axes property of the Artist, as well as the default Axes
+transformation (unless a transformation is set). It also inspects the
+data contained in the Artist to update the data structures controlling
+auto-scaling, so that the view limits can be adjusted to contain the
+plotted data. You can, nonetheless, create objects yourself and add
+them directly to the Axes using helper methods like ax.add_line and
+ax.add_patch. Here is an annotated interactive session illustrating
+what is going on::
+
+ In [261]: fig = plt.figure()
+
+ In [262]: ax = fig.add_subplot(111)
+
+ # create a rectangle instance
+ In [263]: rect = matplotlib.patches.Rectangle( (1,1), width=5, height=12)
+
+ # by default the axes instance is None
+ In [264]: print rect.get_axes()
+ None
+
+ # and the transformation instance is set to the "identity transform"
+ In [265]: print rect.get_transform()
+ <Affine object at 0x13695544>
+
+ # now we add the Rectangle to the Axes
+ In [266]: ax.add_patch(rect)
+
+ # and notice that the ax.add_patch method has set the axes
+ # instance
+ In [267]: print rect.get_axes()
+ Subplot(49,81.25)
+
+ # and the transformation has been set too
+ In [268]: print rect.get_transform()
+ <Affine object at 0x15009ca4>
+
+ # the default axes transformation is ax.transData
+ In [269]: print ax.transData
+ <Affine object at 0x15009ca4>
+
+ # notice that the xlimits of the Axes have not been changed
+ In [270]: print ax.get_xlim()
+ (0.0, 1.0)
+
+ # but the data limits have been updated to encompass the rectangle
+ In [271]: print ax.dataLim.get_bounds()
+ (1.0, 1.0, 5.0, 12.0)
+
+ # we can manually invoke the auto-scaling machinery
+ In [272]: ax.autoscale_view()
+
+ # and now the xlim are updated to encompass the rectangle
+ In [273]: print ax.get_xlim()
+ (1.0, 6.0)
+
+ # we have to manually force a figure draw
+ In [274]: ax.figure.canvas.draw()
+
+
+There are many, many Axes helper methods for creating primitive
+Artists and adding them to their respective containers. The table
+below summarizes a small sampling of them, the kinds of Artist they
+create, and where they store them
+
+============================== ==================== =======================
+Helper method Artist Container
+============================== ==================== =======================
+ax.annotate - text annotations Annotate ax.texts
+ax.bar - bar charts Rectangle ax.patches
+ax.errorbar - error bar plots Line2D and Rectangle ax.lines and ax.patches
+ax.fill - shared area Polygon ax.patches
+ax.hist - histograms Rectangle ax.patches
+ax.imshow - image data AxesImage ax.images
+ax.legend - axes legends Legend ax.legends
+ax.plot - xy plots Line2D ax.lines
+ax.scatter - scatter charts PolygonCollection ax.collections
+ax.text - text Text ax.texts
+============================== ==================== =======================
+
+
+In addition to all of these Artists, the Axes contains two important
+Artist containers: the XAxis and YAxis, which handle the drawing of
+the ticks and labels. These are stored as instance variables xaxis
+and yaxis. The XAxis and YAxis containers will be detailed below, but
+note that the Axes contains many helper methods which forward calls on
+to the Axis instances so you often do not need to work with them
+directly unless you want to. For example, you can set the fontsize of
+the XAxis ticklabels using the Axes helper method::
+
+ for label in ax.get_xticklabels():
+ label.set_color('orange')
+
+Below is a summary of the Artists that the Axes contains
+
+============== ======================================
+Axes attribute Description
+============== ======================================
+artists A list of Artist instances
+axesPatch Rectangle instance for Axes background
+collections A list of Collection instances
+images A list of AxesImage
+legends A list of Legend instances
+lines A list of Line2D instances
+patches A list of Patch instances
+texts A list of Text instances
+xaxis matplotlib.axis.XAxis instance
+yaxis matplotlib.axis.YAxis instance
+============== ======================================
+
+The Axis containers
+-------------------
+
+The matplotlib.axis.Axis instances handle the drawing of the tick lines, the grid
+lines, the tick labels and the axis label. You can configure the left
+and right ticks separately for the y axis, and the upper and lower
+ticks separately for the x axis. The axis also stores the data and view
+intervals used in auto-scaling, panning and zooming, as well as the
+locator and formatter instances which control where the ticks are
+placed and how they are represented as strings.
+
+Each axis object contains a label attribute (this is what the pylab
+calls to xlabel and ylabel set) as well as a list of major and minor
+ticks. The ticks are XTick and YTick instances, which contain the
+actual line and text primitives that render the ticks and ticklabels.
+Because the ticks are dynamically created as needed (eg when panning
+and zooming), you should access the lists of major and minor ticks
+through their accessor methods axis.get_major_ticks() and
+axis.get_minor_ticks(). Although the ticks contain all the primitives
+and will be covered below, the Axis methods contain accessor methods
+to return the tick lines, tick labels, tick locations etc....::
+
+ In [285]: axis = ax.xaxis
+
+ In [286]: axis.get_ticklocs()
+ Out[286]: array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
+
+ In [287]: axis.get_ticklabels()
+ Out[287]: <a list of 10 Text major ticklabel objects>
+
+ # note there are twice as many ticklines as labels because by
+ # default there are tick lines at the top and bottom but only tick
+ # labels below the xaxis; this can be customized
+ In [288]: axis.get_ticklines()
+ Out[288]: <a list of 20 Line2D ticklines objects>
+
+ # by default you get the major ticks back
+ In [291]: axis.get_ticklines()
+ Out[291]: <a list of 20 Line2D ticklines objects>
+
+ # but you can also ask for the minor ticks
+ In [292]: axis.get_ticklines(minor=True)
+ Out[292]: <a list of 0 Line2D ticklines objects>
+
+Here is a summary of some of the useful accessor methods of the Axis
+(these have corresponding setters where useful, such as
+set_major_formatter)
+
+====================== =========================================================
+Accessor method Description
+====================== =========================================================
+get_scale The scale of the axis, eg 'log' or 'linear'
+get_view_interval The interval instance of the axis view limits
+get_data_interval The interval instance of the axis data limits
+get_gridlines A list of grid lines for the Axis
+get_label The axis label - a Text instance
+get_ticklabels A list of Text instances - keyword minor=True|False
+get_ticklines A list of Line2D instances - keyword minor=True|False
+get_ticklocs A list of Tick locations - keyword minor=True|False
+get_major_locator The matplotlib.ticker.Locator instance for major ticks
+get_major_formatter The matplotlib.ticker.Formatter instance for major ticks
+get_minor_locator The matplotlib.ticker.Locator instance for minor ticks
+get_minor_formatter The matplotlib.ticker.Formatter instance for minor ticks
+get_major_ticks A list of Tick instances for major ticks
+get_minor_ticks A list of Tick instances for minor ticks
+grid Turn the grid on or off for the major or minor ticks
+====================== =========================================================
+
+Try creating the figure below
+
+.. image:: figures/fig_axes_customize_simple.png
+ :scale: 75
+
+Exercise solution::
+
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ # plt.figure creates a matplotlib.figure.Figure instance
+ fig = plt.figure()
+ rect = fig.figurePatch # a rectangle instance
+ rect.set_facecolor('lightgoldenrodyellow')
+
+ ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4])
+ rect = ax1.axesPatch
+ rect.set_facecolor('lightslategray')
+
+
+ for label in ax1.xaxis.get_ticklabels():
+ # label is a Text instance
+ label.set_color('red')
+ label.set_rotation(45)
+ label.set_fontsize(16)
+
+ for line in ax1.yaxis.get_ticklines():
+ # line is a Line2D instance
+ line.set_color('green')
+ line.set_markersize(25)
+ line.set_markeredgewidth(3)
+
+ fig.savefig('figures/fig_axes_customize_simple.png', dpi=150)
+ fig.savefig('figures/fig_axes_customize_simple.eps')
+ plt.show()
+
+
+
+The Tick containers
+-------------------
+
+The matplotlib.axis.Tick is the final container object in our descent
+from the Figure to the Axes to the Axis to the Tick. The Tick
+contains the tick and grid line instances, as well as the label
+instances for the upper and lower ticks. Each of these is accessible
+directly as an attribute of the Tick. In addition, there are boolean
+variables that determine whether the upper labels and ticks are on for
+the xaxis and whether the right labels and ticks are on for the yaxis.
+
+============== ==========================================================
+Tick attribute Description
+============== ==========================================================
+tick1line Line2D instance
+tick2line Line2D instance
+gridline Line2D instance
+label1 Text instance
+label2 Text instance
+gridOn boolean which determines whether to draw the tickline
+tick1On boolean which determines whether to draw the 1st tickline
+tick2On boolean which determines whether to draw the 2nd tickline
+label1On boolean which determines whether to draw tick label
+label2On boolean which determines whether to draw tick label
+============== ==========================================================
+
+Here is an example which sets the formatter for the upper ticks with
+dollar signs and colors them green on the right side of the yaxis::
+
+ import numpy as np
+ import matplotlib.pyplot as plt
+ import matplotlib.ticker as ticker
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.plot(100*np.random.rand(20))
+
+ formatter = ticker.FormatStrFormatter('$%1.2f')
+ ax.yaxis.set_major_formatter(formatter)
+
+ for tick in ax.yaxis.get_major_ticks():
+ tick.label1On = False
+ tick.label2On = True
+ tick.label2.set_color('green')
+
+ plt.show()
+
+
+.. image:: figures/dollar_ticks.png
+ :scale: 75
Added: trunk/matplotlib/doc/event_handling_tut.txt
===================================================================
--- trunk/matplotlib/doc/event_handling_tut.txt (rev 0)
+++ trunk/matplotlib/doc/event_handling_tut.txt 2008-03-21 17:51:06 UTC (rev 5014)
@@ -0,0 +1,470 @@
+Event Handling and Picking Tutorial
+===================================
+
+matplotlib works with 5 user interface toolkits (wxpython, tkinter,
+qt, gtk and fltk) and in order to support features like interactive
+panning and zooming of figures, it is helpful to the developers to
+have an API for interacting with the figure via key presses and mouse
+movements that is "GUI neutral" so we don't have to repeat a lot of
+code across the different user interfaces. Although the event
+handling API is GUI neutral, it is based on the GTK model, which was
+the first user interface matplotlib supported. The events that are
+triggered are also a bit richer vis-a-vis matplotlib than standard GUI
+events, including information like which Axes the event occurred in.
+The events also understand the matplotlib coordinate system, and
+report event locations in both pixel and data coordinates.
+
+
+Event connections
+=================
+
+To receive events, you need to write a callback function and then
+connect your function to the event manager, which is part of the
+FigureCanvas. Here is a simple example that prints the location of
+the mouse click and which button was pressed::
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.plot(np.random.rand(10))
+
+ def onclick(event):
+ print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(
+ event.button, event.x, event.y, event.xdata, event.ydata)
+
+ cid = fig.canvas.mpl_connect('button_press_event', onclick)
+
+The FigureCanvas method mpl_connect returns a connection id which is
+simply an integer. When you want to disconnect the callback, just
+call::
+
+ fig.canvas.mpl_disconnect(cid)
+
+Here are the events that you can connect to, the class instances that
+are sent back to you when the event occurs, and the event descriptions
+
+
+===================== =========== ===================================
+Event name Class Description
+===================== =========== ===================================
+button_press_event MouseEvent mouse button is pressed
+button_release_event MouseEvent mouse button is released
+draw_event DrawEvent canvas draw
+key_press_event KeyEvent key is pressed
+key_release_event KeyEvent key is released
+motion_notify_event MouseEvent mouse motion
+pick_event PickEvent an object in the canvas is selected
+resize_event ResizeEvent figure canvas is resized
+scroll_event MouseEvent mouse scroll wheel is rolled
+===================== =========== ===================================
+
+
+Event attributes
+================
+
+All matplotlib events inherit from the base class
+matplotlib.backend_bases.Event, which store the attributes
+
+=============== =================================================
+Event attribute Description
+=============== =================================================
+name the event name
+canvas the FigureCanvas instance generating the event
+guiEvent the GUI event that triggered the matplotlib event
+=============== =================================================
+
+The most common events that are the bread and butter of event handling
+are key press/release events and mouse press/release and movement
+events. The KeyEvent and MouseEvent classes that handle these events
+are both derived from the LocationEvent, which has the following
+attributes
+
+======================= ========================================
+LocationEvent attribute Description
+======================= ========================================
+x x position - pixels from left of canvas
+y y position - pixels from right of canvas
+button button pressed None, 1, 2, 3
+inaxes the Axes instance if mouse us over axes
+xdata x coord of mouse in data coords
+ydata y coord of mouse in data coords
+======================= ========================================
+
+Let's look a simple example of a canvas, where a simple line segment
+is created every time a mouse is pressed::
+
+ class LineBuilder:
+ def __init__(self, line):
+ self.line = line
+ self.xs = list(line.get_xdata())
+ self.ys = list(line.get_ydata())
+ self.cid = line.figure.canvas.mpl_connect('button_press_event', self)
+
+ def __call__(self, event):
+ print 'click', event
+ if event.inaxes!=self.line.axes: return
+ self.xs.append(event.xdata)
+ self.ys.append(event.ydata)
+ self.line.set_data(self.xs, self.ys)
+ self.line.figure.canvas.draw()
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.set_title('click to build line segments')
+ line, = ax.plot([0], [0]) # empty line
+ linebuilder = LineBuilder(line)
+
+
+
+The MouseEvent that we just used is a LocationEvent, so we have access
+to the data and pixel coordinates in event.x and event.xdata. In
+addition to the LocationEvent attributes, it has
+
+==================== ==============================================================
+MouseEvent attribute Description
+==================== ==============================================================
+button button pressed None, 1, 2, 3
+key the key pressed: None, chr(range(255)), shift, win, or control
+==================== ==============================================================
+
+Draggable Rectangle Exercise
+----------------------------
+
+Write draggable rectangle class that is initialized with a Rectangle
+instance but will move its x,y location when dragged. Hint: you will
+need to store the orginal xy location of the rectangle which is stored
+as rect.xy and connect to the press, motion and release mouse events.
+When the mouse is pressed, check to see if the click occurs over your
+rectangle (see rect.contains) and if it does, store the rectangle xy
+and the location of the mouse click in data coords. In the motion
+event callback, compute the deltax and deltay of the mouse movement,
+and add those deltas to the origin of the rectangle you stored. The
+redraw the figure. On the button release event, just reset all the
+button press data you stored as None.
+
+Here is the solution::
+
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ class DraggableRectangle:
+ def __init__(self, rect):
+ self.rect = rect
+ self.press = None
+
+ def connect(self):
+ 'connect to all the events we need'
+ self.cidpress = self.rect.figure.canvas.mpl_connect(
+ 'button_press_event', self.on_press)
+ self.cidrelease = self.rect.figure.canvas.mpl_connect(
+ 'button_release_event', self.on_release)
+ self.cidmotion = self.rect.figure.canvas.mpl_connect(
+ 'motion_notify_event', self.on_motion)
+
+ def on_press(self, event):
+ 'on button press we will see if the mouse is over us and store some data'
+ if event.inaxes != self.rect.axes: return
+
+ contains, attrd = self.rect.contains(event)
+ if not contains: return
+ print 'event contains', self.rect.xy
+ x0, y0 = self.rect.xy
+ self.press = x0, y0, event.xdata, event.ydata
+
+ def on_motion(self, event):
+ 'on motion we will move the rect if the mouse is over us'
+ if self.press is None: return
+ if event.inaxes != self.rect.axes: return
+ x0, y0, xpress, ypress = self.press
+ dx = event.xdata - xpress
+ dy = event.ydata - ypress
+ #print 'x0=%f, xpress=%f, event.xdata=%f, dx=%f, x0+dx=%f'%(x0, xpress, event.xdata, dx, x0+dx)
+ self.rect.set_x(x0+dx)
+ self.rect.set_y(y0+dy)
+
+ self.rect.figure.canvas.draw()
+
+
+ def on_release(self, event):
+ 'on release we reset the press data'
+ self.press = None
+ self.rect.figure.canvas.draw()
+
+ def disconnect(self):
+ 'disconnect all the stored connection ids'
+ self.rect.figure.canvas.mpl_disconnect(self.cidpress)
+ self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
+ self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ rects = ax.bar(range(10), 20*np.random.rand(10))
+ drs = []
+ for rect in rects:
+ dr = DraggableRectangle(rect)
+ dr.connect()
+ drs.append(dr)
+
+ plt.show()
+
+
+**Extra credit**: use the animation blit techniques discussed at
+http://www.scipy.org/Cookbook/Matplotlib/Animations to make the
+animated drawing faster and smoother.
+
+Extra credit solution::
+
+ # draggable rectangle with the animation blit techniques; see
+ # http://www.scipy.org/Cookbook/Matplotlib/Animations
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ class DraggableRectangle:
+ lock = None # only one can be animated at a time
+ def __init__(self, rect):
+ self.rect = rect
+ self.press = None
+ self.background = None
+
+ def connect(self):
+ 'connect to all the events we need'
+ self.cidpress = self.rect.figure.canvas.mpl_connect(
+ 'button_press_event', self.on_press)
+ self.cidrelease = self.rect.figure.canvas.mpl_connect(
+ 'button_release_event', self.on_release)
+ self.cidmotion = self.rect.figure.canvas.mpl_connect(
+ 'motion_notify_event', self.on_motion)
+
+ def on_press(self, event):
+ 'on button press we will see if the mouse is over us and store some data'
+ if event.inaxes != self.rect.axes: return
+ if DraggableRectangle.lock is not None: return
+ contains, attrd = self.rect.contains(event)
+ if not contains: return
+ print 'event contains', self.rect.xy
+ x0, y0 = self.rect.xy
+ self.press = x0, y0, event.xdata, event.ydata
+ DraggableRectangle.lock = self
+
+ # draw everything but the selected rectangle and store the pixel buffer
+ canvas = self.rect.figure.canvas
+ axes = self.rect.axes
+ self.rect.set_animated(True)
+ canvas.draw()
+ self.background = canvas.copy_from_bbox(self.rect.axes.bbox)
+
+ # now redraw just the rectangle
+ axes.draw_artist(self.rect)
+
+ # and blit just the redrawn area
+ canvas.blit(axes.bbox)
+
+ def on_motion(self, event):
+ 'on motion we will move the rect if the mouse is over us'
+ if DraggableRectangle.lock is not self:
+ return
+ if event.inaxes != self.rect.axes: return
+ x0, y0, xpress, ypress = self.press
+ dx = event.xdata - xpress
+ dy = event.ydata - ypress
+ self.rect.set_x(x0+dx)
+ self.rect.set_y(y0+dy)
+
+
+ canvas = self.rect.figure.canvas
+ axes = self.rect.axes
+ # restore the background region
+ canvas.restore_region(self.background)
+
+ # redraw just the current rectangle
+ axes.draw_artist(self.rect)
+
+ # blit just the redrawn area
+ canvas.blit(axes.bbox)
+
+
+
+ def on_release(self, event):
+ 'on release we reset the press data'
+ if DraggableRectangle.lock is not self:
+ return
+
+ self.press = None
+ DraggableRectangle.lock = None
+
+ # turn off the rect animation property and reset the background
+ self.rect.set_animated(False)
+ self.background = None
+
+ # redraw the full figure
+ self.rect.figure.canvas.draw()
+ def disconnect(self):
+ 'disconnect all the stored connection ids'
+ self.rect.figure.canvas.mpl_disconnect(self.cidpress)
+ self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
+ self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ rects = ax.bar(range(10), 20*np.random.rand(10))
+ drs = []
+ for rect in rects:
+ dr = DraggableRectangle(rect)
+ dr.connect()
+ drs.append(dr)
+
+ plt.show()
+
+
+Object Picking
+==============
+
+You can enable picking by setting the ``picker`` property of an Artist
+(eg a matplotlib Line2D, Text, Patch, Polygon, AxesImage,
+etc...)
+
+There are a variety of meanings of the picker property:
+
+- None : picking is disabled for this artist (default)
+
+- boolean : if True then picking will be enabled and the artist will
+ fire a pick event if the mouse event is over the artist
+
+- float : if picker is a number it is interpreted as an epsilon
+ tolerance in points and the the artist will fire off an event if its
+ data is within epsilon of the mouse event. For some artists like
+ lines and patch collections, the artist may provide additional data
+ to the pick event that is generated, eg the indices of the data
+ within epsilon of the pick event.
+
+- function : if picker is callable, it is a user supplied function
+ which determines whether the artist is hit by the mouse event. The
+ signature is ``hit, props = picker(artist, mouseevent)`` to
+ determine the hit test. If the mouse event is over the artist,
+ return hit=True and props is a dictionary of properties you want
+ added to the PickEvent attributes
+
+
+After you have enabled an artist for picking by setting the ``picker``
+property, you need to connect to the figure canvas pick_event to get
+pick callbacks on mouse press events. Eg::
+
+ def pick_handler(event):
+ mouseevent = event.mouseevent
+ artist = event.artist
+ # now do something with this...
+
+
+The pick event (matplotlib.backend_bases.PickEvent) which is passed to
+your callback is always fired with two attributes:
+
+- mouseevent : the mouse event that generate the pick event. The
+ mouse event in turn has attributes like x and y (the coords in
+ display space, eg pixels from left, bottom) and xdata, ydata (the
+ coords in data space). Additionally, you can get information about
+ which buttons were pressed, which keys were pressed, which Axes the
+ mouse is over, etc. See matplotlib.backend_bases.MouseEvent for
+ details.
+
+- artist : the matplotlib.artist that generated the pick event.
+
+Additionally, certain artists like Line2D and PatchCollection may
+attach additional meta data like the indices into the data that meet
+the picker criteria (eg all the points in the line that are within the
+specified epsilon tolerance)
+
+Simple picking example
+----------------------
+
+In the example below, we set the line picker property to a scalar, so
+it represents a tolerance in points (72 points per inch). The onpick
+callback function will be called when the pick event it within the
+tolerance distance from the line, and has the indices of the data
+vertices that are within the pick distance tolerance. Our onpick
+callback function simply prints the data that are under the pick
+location. Different matplotlib Artists can attach different data to
+the PickEvent. For example, Line2D attaches the ind property, which
+are the indices into the line data under the pick point. See
+Line2D.pick for details on the PickEvent properties of the line. Here
+is the code::
+
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.set_title('click on points')
+
+ line, = ax.plot(np.random.rand(100), 'o', picker=5) # 5 points tolerance
+
+ def onpick(event):
+ thisline = event.artist
+ xdata = thisline.get_xdata()
+ ydata = thisline.get_ydata()
+ ind = event.ind
+ print 'onpick points:', zip(xdata[ind], ydata[ind])
+
+ fig.canvas.mpl_connect('pick_event', onpick)
+
+ plt.show()
+
+
+Picking Exercise
+----------------
+
+Create a data set of 100 arrays of 1000 Gaussian random numbers and
+compute the sample mean and standard deviation of each of them (hint:
+numpy arrays have a mean and std method) and make a xy marker plot of
+the 100 means vs the 100 standard deviations. Connect the line
+created by the plot command to the pick event, and plot the original
+time series of the data that generated the clicked on points. If more
+than one point is within the tolerance of the clicked on point, you
+can use multiple subplots to plot the multiple time series.
+
+Exercise solution::
+
+ """
+ compute the mean and stddev of 100 data sets and plot mean vs stddev.
+ When you click on one of the mu, sigma points, plot the raw data from
+ the dataset that generated the mean and stddev
+ """
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ X = np.random.rand(100, 1000)
+ xs = np.mean(X, axis=1)
+ ys = np.std(X, axis=1)
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.set_title('click on point to plot time series')
+ line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
+
+
+ def onpick(event):
+
+ if event.artist!=line: return True
+
+ N = len(event.ind)
+ if not N: return True
+
+
+ figi = plt.figure()
+ for subplotnum, dataind in enumerate(event.ind):
+ ax = figi.add_subplot(N,1,subplotnum+1)
+ ax.plot(X[dataind])
+ ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
+ transform=ax.transAxes, va='top')
+ ax.set_ylim(-0.5, 1.5)
+ figi.show()
+ return True
+
+ fig.canvas.mpl_connect('pick_event', onpick)
+
+ plt.show()
+
+
+
+
+
+
+
Added: trunk/matplotlib/doc/figures/dollar_ticks.py
===================================================================
--- trunk/matplotlib/doc/figures/dollar_ticks.py (rev 0)
+++ trunk/matplotlib/doc/figures/dollar_ticks.py 2008-03-21 17:51:06 UTC (rev 5014)
@@ -0,0 +1,20 @@
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.ticker as ticker
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot(100*np.random.rand(20))
+
+formatter = ticker.FormatStrFormatter('$%1.2f')
+ax.yaxis.set_major_formatter(formatter)
+
+for tick in ax.yaxis.get_major_ticks():
+ tick.label1On = False
+ tick.label2On = True
+ tick.label2.set_color('green')
+
+fig.savefig('dollar_ticks')
+plt.show()
+
+
Added: trunk/matplotlib/doc/figures/fig_axes_customize_simple.py
===================================================================
--- trunk/matplotlib/doc/figures/fig_axes_customize_simple.py (rev 0)
+++ trunk/matplotlib/doc/figures/fig_axes_customize_simple.py 2008-03-21 17:51:06 UTC (rev 5014)
@@ -0,0 +1,29 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+# plt.figure creates a matplotlib.figure.Figure instance
+fig = plt.figure()
+rect = fig.figurePatch # a rectangle instance
+rect.set_facecolor('lightgoldenrodyellow')
+
+ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4])
+rect = ax1.axesPatch
+rect.set_facecolor('lightslategray')
+
+
+for label in ax1.xaxis.get_ticklabels():
+ # label is a Text instance
+ label.set_color('red')
+ label.set_rotation(45)
+ label.set_fontsize(16)
+
+for line in ax1.yaxis.get_ticklines():
+ # line is a Line2D instance
+ line.set_color('green')
+ line.set_markersize(25)
+ line.set_markeredgewidth(3)
+
+
+fig.savefig('fig_axes_customize_simple')
+
+plt.show()
Added: trunk/matplotlib/doc/figures/fig_axes_labels_simple.py
===================================================================
--- trunk/matplotlib/doc/figures/fig_axes_labels_simple.py (rev 0)
+++ trunk/matplotlib/doc/figures/fig_axes_labels_simple.py 2008-03-21 17:51:06 UTC (rev 5014)
@@ -0,0 +1,21 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+fig.subplots_adjust(top=0.8)
+ax1 = fig.add_subplot(211)
+ax1.set_ylabel('volts')
+ax1.set_title('a sine wave')
+
+t = np.arange(0.0, 1.0, 0.01)
+s = np.sin(2*np.pi*t)
+line, = ax1.plot(t, s, color='blue', lw=2)
+
+ax2 = fig.add_axes([0.15, 0.1, 0.7, 0.3])
+n, bins, patches = ax2.hist(np.random.randn(1000), 50,
+ facecolor='yellow', edgecolor='yellow')
+ax2.set_xlabel('time (s)')
+
+fig.savefig('fig_axes_labels_simple')
+
+plt.show()
Added: trunk/matplotlib/doc/figures/make.py
===================================================================
--- trunk/matplotlib/doc/figures/make.py (rev 0)
+++ trunk/matplotlib/doc/figures/make.py 2008-03-21 17:51:06 UTC (rev 5014)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+import sys, os, glob
+import matplotlib
+matplotlib.use('Agg')
+
+def figs():
+ # each one of these will make a figure when imported
+ import dollar_ticks
+ import fig_axes_customize_simple
+ import fig_axes_labels_simple
+
+ print 'all figures made'
+ for fname in glob.glob('*.pyc'):
+ os.remove(fname)
+
+def clean():
+ patterns = ['#*', '*~', '*.png']
+ for pattern in patterns:
+ for fname in glob.glob(pattern):
+ os.remove(fname)
+ print 'all clean'
+
+
+
+def all():
+ figs()
+
+funcd = {'figs':figs,
+ 'clean':clean,
+ 'all':all,
+ }
+
+if len(sys.argv)>1:
+ for arg in sys.argv[1:]:
+ func = funcd.get(arg)
+ if func is None:
+ raise SystemExit('Do not know how to handle %s; valid args are'%(
+ arg, funcd.keys()))
+ func()
+else:
+ all()
+
+
+
+
Property changes on: trunk/matplotlib/doc/figures/make.py
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/matplotlib/doc/make.py
===================================================================
--- trunk/matplotlib/doc/make.py (rev 0)
+++ trunk/matplotlib/doc/make.py 2008-03-21 17:51:06 UTC (rev 5014)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+import os, sys, glob
+
+def check_png():
+ if not len(glob.glob('figures/*.png')):
+ raise SystemExit('No PNG files in figures dir; please run make.py in the figures directory first')
+
+def check_rst2latex():
+ sin, sout = os.popen2('which rst2latex')
+ if not sout.read():
+ raise SystemExit('Build requires rst2latex')
+
+def check_pdflatex():
+ sin, sout = os.popen2('which pdflatex')
+ if not sout.read():
+ raise SystemExit('Build requires pdflatex')
+
+
+
+
+def artist_tut():
+ check_png()
+ check_rst2latex()
+ check_pdflatex()
+ os.system('rst2latex artist_api_tut.txt > artist_api_tut.tex')
+ os.system('pdflatex artist_api_tut.tex')
+
+
+def event_tut():
+ check_png()
+ check_rst2latex()
+ check_pdflatex()
+ os.system('rst2latex event_handling_tut.txt > event_handling_tut.tex')
+ os.system('pdflatex event_handling_tut.tex')
+
+def clean():
+ patterns = ['#*', '*~', '*.tex', '*.log', '*.out', '*.aux']
+ for pattern in patterns:
+ for fname in glob.glob(pattern):
+ os.remove(fname)
+ print 'all clean'
+
+def all():
+ artist_tut()
+ event_tut()
+
+funcd = {'artist_tut': artist_tut,
+ 'event_tut': event_tut,
+ 'clean': clean,
+ 'all': all,
+ }
+
+if len(sys.argv)>1:
+ for arg in sys.argv[1:]:
+ func = funcd.get(arg)
+ if func is None:
+ raise SystemExit('Do not know how to handle %s; valid args are'%(
+ arg, funcd.keys()))
+ func()
+else:
+ all()
+
+
+
+
+
+
+
+
+
+
Property changes on: trunk/matplotlib/doc/make.py
___________________________________________________________________
Name: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-03-21 17:19:43
|
Revision: 5013
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5013&view=rev
Author: mmetz_bn
Date: 2008-03-21 10:19:37 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
Bugfix in ContourSet._process_linestyles
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/contour.py
Modified: branches/v0_91_maint/lib/matplotlib/contour.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/contour.py 2008-03-21 13:26:27 UTC (rev 5012)
+++ branches/v0_91_maint/lib/matplotlib/contour.py 2008-03-21 17:19:37 UTC (rev 5013)
@@ -708,7 +708,7 @@
else:
if cbook.is_string_like(linestyles):
tlinestyles = [linestyles] * Nlev
- elif cbook.iterable(linestyles) and len(linestyles) < Nlev:
+ elif cbook.iterable(linestyles) and len(linestyles) <= Nlev:
tlinestyles = list(linestyles) * int(npy.ceil(Nlev/len(linestyles)))
return tlinestyles
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-03-21 13:26:39
|
Revision: 5012
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5012&view=rev
Author: mdboom
Date: 2008-03-21 06:26:27 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
Merged revisions 4999-5011 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
........
r5011 | mdboom | 2008-03-21 09:10:20 -0400 (Fri, 21 Mar 2008) | 3 lines
Bugfix: [ 1912719 ] TypeError in Exception __get_configdir()
Thanks, Andrea Tomasini
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/__init__.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-4998
+ /branches/v0_91_maint:1-5011
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2008-03-21 13:10:20 UTC (rev 5011)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-03-21 13:26:27 UTC (rev 5012)
@@ -397,7 +397,7 @@
if os.path.exists(p):
if not _is_writable_dir(p):
- raise RuntimeError("'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored "%h)
+ raise RuntimeError("'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored "% (h, h))
else:
if not _is_writable_dir(h):
raise RuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|