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: <ef...@us...> - 2009-06-06 18:18:59
|
Revision: 7187
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7187&view=rev
Author: efiring
Date: 2009-06-06 18:18:54 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
Update CHANGELOG
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-06-06 14:16:40 UTC (rev 7186)
+++ trunk/matplotlib/CHANGELOG 2009-06-06 18:18:54 UTC (rev 7187)
@@ -1,6 +1,9 @@
-2009-06-03 axes_grid : Initial check-in of curvelinear grid support. See
+
+2009-06-03 axes_grid : Initial check-in of curvelinear grid support. See
examples/axes_grid/demo_curvelinear_grid.py - JJL
+2009-06-01 Add set_color method to Patch - EF
+
2009-06-01 Spine is now derived from Patch - ADS
2009-06-01 use cbook.is_string_like() instead of isinstance() for spines - ADS
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-06 14:16:41
|
Revision: 7186
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7186&view=rev
Author: jdh2358
Date: 2009-06-06 14:16:40 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
added a properties method to the artist and inspector to return a dict mapping property name -> value; see sf feature request 2792183
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/artist.py
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py 2009-06-06 13:26:49 UTC (rev 7185)
+++ trunk/matplotlib/lib/matplotlib/artist.py 2009-06-06 14:16:40 UTC (rev 7186)
@@ -672,6 +672,12 @@
self.pchanged()
+ def properties(self):
+ """
+ return a dictionary mapping property name -> value for all Artist props
+ """
+ return ArtistInspector(self).properties()
+
def set(self, **kwargs):
"""
A tkstyle set command, pass *kwargs* to set properties
@@ -876,6 +882,7 @@
return ':meth:`%s <%s>`%s' % (s, target, aliases)
+
def pprint_setters(self, prop=None, leadingspace=2):
"""
If *prop* is *None*, return a list of strings of all settable properies
@@ -954,24 +961,39 @@
lines.append('%s%s: %s' %(pad, name, accepts))
return lines
- def pprint_getters(self):
+
+ def properties(self):
"""
- Return the getters and actual values as list of strings.
+ return a dictionary mapping property name -> value
"""
-
o = self.oorig
getters = [name for name in dir(o)
if name.startswith('get_')
and callable(getattr(o, name))]
#print getters
getters.sort()
- lines = []
+ d = dict()
for name in getters:
func = getattr(o, name)
if self.is_alias(func): continue
try: val = func()
except: continue
+ else: d[name[4:]] = val
+
+ return d
+
+ def pprint_getters(self):
+ """
+ Return the getters and actual values as list of strings.
+ """
+
+ d = self.properties()
+ names = d.keys()
+ names.sort()
+ lines = []
+ for name in names:
+ val = d[name]
if getattr(val, 'shape', ()) != () and len(val)>6:
s = str(val[:6]) + '...'
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-06 13:26:51
|
Revision: 7185
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7185&view=rev
Author: jdh2358
Date: 2009-06-06 13:26:49 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
added Neil's auto minor tick patch; sf patch #2789713
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/pyplot.py
trunk/matplotlib/lib/matplotlib/ticker.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-06-06 11:36:10 UTC (rev 7184)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-06-06 13:26:49 UTC (rev 7185)
@@ -7790,7 +7790,19 @@
return _bbox
+ def minorticks_on(self):
+ 'Add autoscaling minor ticks to the axes.'
+ for ax in (self.xaxis, self.yaxis):
+ if ax.get_scale() == 'log':
+ s = ax._scale
+ ax.set_minor_locator(mticker.LogLocator(s.base, s.subs))
+ else:
+ ax.set_minor_locator(mticker.AutoMinorLocator())
+ def minorticks_off(self):
+ 'Remove minor ticks from the axes.'
+ self.xaxis.set_minor_locator(mticker.NullLocator())
+ self.yaxis.set_minor_locator(mticker.NullLocator())
class SubplotBase:
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2009-06-06 11:36:10 UTC (rev 7184)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2009-06-06 13:26:49 UTC (rev 7185)
@@ -1047,8 +1047,23 @@
silent_list('Text yticklabel', labels)
)
+def minorticks_on():
+ """
+ Display minor ticks on the current plot.
+ Displaying minor ticks reduces performance; turn them off using
+ minorticks_off() if drawing speed is a problem.
+ """
+ gca().minorticks_on()
+ draw_if_interactive()
+def minorticks_off():
+ """
+ Remove minor ticks from the current plot.
+ """
+ gca().minorticks_off()
+ draw_if_interactive()
+
def rgrids(*args, **kwargs):
"""
Set/Get the radial locations of the gridlines and ticklabels on a
Modified: trunk/matplotlib/lib/matplotlib/ticker.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/ticker.py 2009-06-06 11:36:10 UTC (rev 7184)
+++ trunk/matplotlib/lib/matplotlib/ticker.py 2009-06-06 13:26:49 UTC (rev 7185)
@@ -1182,6 +1182,40 @@
def __init__(self):
MaxNLocator.__init__(self, nbins=9, steps=[1, 2, 5, 10])
+class AutoMinorLocator(Locator):
+ """
+ Dynamically find minor tick positions based on the positions of
+ major ticks. Assumes the scale is linear and major ticks are
+ evenly spaced.
+ """
+ def __call__(self):
+ 'Return the locations of the ticks'
+ majorlocs = self.axis.get_majorticklocs()
+ try:
+ majorstep = majorlocs[1] - majorlocs[0]
+ except IndexError:
+ raise ValueError('Need at least two major ticks to find minor '
+ 'tick locations')
+ # see whether major step should be divided by 5, 4 or 2. This
+ # should cover most cases.
+ temp = float(('%e' % majorstep).split('e')[0])
+ if temp % 5 < 1e-10:
+ minorstep = majorstep / 5.
+ elif temp % 2 < 1e-10:
+ minorstep = majorstep / 4.
+ else:
+ minorstep = majorstep / 2.
+
+ tmin = majorlocs[0] - majorstep
+ tmax = majorlocs[-1] + majorstep
+ locs = np.arange(tmin, tmax, minorstep)
+ vmin, vmax = self.axis.get_view_interval()
+ if vmin > vmax:
+ vmin,vmax = vmax,vmin
+
+ return locs[(vmin < locs) & (locs < vmax)]
+
+
class OldAutoLocator(Locator):
"""
On autoscale this class picks the best MultipleLocator to set the
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-06 11:36:12
|
Revision: 7184
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7184&view=rev
Author: jdh2358
Date: 2009-06-06 11:36:10 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
do not apply alpha to rgba color conversion if input is already rgba
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/collections.py
trunk/matplotlib/lib/matplotlib/colors.py
trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2009-06-05 23:45:53 UTC (rev 7183)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2009-06-06 11:36:10 UTC (rev 7184)
@@ -91,6 +91,7 @@
self.set_antialiased(antialiaseds)
self.set_urls(urls)
+
self._uniform_offsets = None
self._offsets = np.array([], np.float_)
if offsets is not None:
@@ -106,6 +107,7 @@
self._pickradius = pickradius
self.update(kwargs)
+
def _get_value(self, val):
try: return (float(val), )
except TypeError:
Modified: trunk/matplotlib/lib/matplotlib/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py 2009-06-05 23:45:53 UTC (rev 7183)
+++ trunk/matplotlib/lib/matplotlib/colors.py 2009-06-06 11:36:10 UTC (rev 7184)
@@ -373,7 +373,11 @@
if isinstance(c, np.ndarray):
if c.ndim != 2 and c.dtype.kind not in 'SU':
raise ValueError("Color array must be two-dimensional")
-
+ if len(c.shape)==2 and c.shape[-1]==4:
+ # looks like rgba already, nothing to be done; do
+ # we want to apply alpha here if
+ # (c[:,3]==1).all() ?
+ return c
result = np.zeros((len(c), 4))
for i, cc in enumerate(c):
result[i] = self.to_rgba(cc, alpha) # change in place
@@ -976,7 +980,7 @@
def __init__(self,azdeg=315,altdeg=45,\
hsv_min_val=0,hsv_max_val=1,hsv_min_sat=1,hsv_max_sat=0):
"""
- Specify the azimuth (measured clockwise from south) and altitude
+ Specify the azimuth (measured clockwise from south) and altitude
(measured up from the plane of the surface) of the light source
in degrees.
@@ -987,7 +991,7 @@
(hsv_max_sat hsv_max_val) in regions that are illuminated.
The default extremes are chose so that completely shaded points
are nearly black (s = 1, v = 0) and completely illuminated points
- are nearly white (s = 0, v = 1).
+ are nearly white (s = 0, v = 1).
"""
self.azdeg = azdeg
self.altdeg = altdeg
@@ -999,10 +1003,10 @@
def shade(self,data,cmap):
"""
Take the input data array, convert to HSV values in the
- given colormap, then adjust those color values
+ given colormap, then adjust those color values
to given the impression of a shaded relief map with a
specified light source.
- RGBA values are returned, which can then be used to
+ RGBA values are returned, which can then be used to
plot the shaded image with imshow.
"""
# imagine an artificial sun placed at infinity in
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2009-06-05 23:45:53 UTC (rev 7183)
+++ trunk/matplotlib/src/_backend_agg.cpp 2009-06-06 11:36:10 UTC (rev 7184)
@@ -465,7 +465,7 @@
if (region->data==NULL)
throw Py::ValueError("Cannot restore_region from NULL data");
- agg::rect_i rect(xx1-region->rect.x1, (yy1-region->rect.y1),
+ agg::rect_i rect(xx1-region->rect.x1, (yy1-region->rect.y1),
xx2-region->rect.x1, (yy2-region->rect.y1));
@@ -1187,6 +1187,7 @@
*(double*)PyArray_GETPTR2(edgecolors, ei, 1),
*(double*)PyArray_GETPTR2(edgecolors, ei, 2),
*(double*)PyArray_GETPTR2(edgecolors, ei, 3));
+
if (Nlinewidths) {
gc.linewidth = double(Py::Float(linewidths[i % Nlinewidths])) * dpi/72.0;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-06-05 23:45:54
|
Revision: 7183
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7183&view=rev
Author: leejjoon
Date: 2009-06-05 23:45:53 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
axes_grid/clip_path.py : fix math domain error
Modified Paths:
--------------
trunk/matplotlib/lib/mpl_toolkits/axes_grid/clip_path.py
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/clip_path.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/clip_path.py 2009-06-05 16:53:47 UTC (rev 7182)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/clip_path.py 2009-06-05 23:45:53 UTC (rev 7183)
@@ -1,6 +1,12 @@
import numpy as np
-from math import degrees, atan2
+from math import degrees
+import math
+def atan2(dy, dx):
+ if dx == 0 and dx == 0:
+ return 0
+ else:
+ return math.atan2(dy, dx)
# FIXME : The current algorithm seems to return incorrect angle when the line
# ends at the boudnary.
@@ -38,6 +44,10 @@
ns = -1
segx, segy = [], []
+ if dx == 0. and dy == 0:
+ dx = x[+1] - x[i]
+ dy = y[i+1] - y[i]
+
a = degrees(atan2(dy, dx))
_pos_angles.append((x0, y0, a))
@@ -48,6 +58,10 @@
segx, segy = [x0], [y0]
ns = i+1
+ if dx == 0. and dy == 0:
+ dx = x[+1] - x[i]
+ dy = y[i+1] - y[i]
+
a = degrees(atan2(dy, dx))
_pos_angles.append((x0, y0, a))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-05 16:53:48
|
Revision: 7182
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7182&view=rev
Author: jdh2358
Date: 2009-06-05 16:53:47 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
updated backend driver to find the new fill_between examples
Modified Paths:
--------------
trunk/matplotlib/examples/tests/backend_driver.py
Modified: trunk/matplotlib/examples/tests/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/tests/backend_driver.py 2009-06-05 16:53:11 UTC (rev 7181)
+++ trunk/matplotlib/examples/tests/backend_driver.py 2009-06-05 16:53:47 UTC (rev 7182)
@@ -86,7 +86,7 @@
'figimage_demo.py',
'figlegend_demo.py',
'figure_title.py',
- 'fill_between.py',
+ 'fill_between_demo.py',
'fill_demo.py',
'fill_demo2.py',
'fill_spiral.py',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-05 16:53:13
|
Revision: 7181
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7181&view=rev
Author: jdh2358
Date: 2009-06-05 16:53:11 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
renamed fill_between.py and fill_betweenx.py to have _demo postfix
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/fill_between_demo.py
trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab_examples/fill_between.py
trunk/matplotlib/examples/pylab_examples/fill_betweenx.py
Deleted: trunk/matplotlib/examples/pylab_examples/fill_between.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:51:21 UTC (rev 7180)
+++ trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:53:11 UTC (rev 7181)
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-import matplotlib.mlab as mlab
-from matplotlib.pyplot import figure, show
-import numpy as np
-
-x = np.arange(0.0, 2, 0.01)
-y1 = np.sin(2*np.pi*x)
-y2 = 1.2*np.sin(4*np.pi*x)
-
-fig = figure()
-ax1 = fig.add_subplot(311)
-ax2 = fig.add_subplot(312, sharex=ax1)
-ax3 = fig.add_subplot(313, sharex=ax1)
-
-ax1.fill_between(x, 0, y1)
-ax1.set_ylabel('between y1 and 0')
-
-ax2.fill_between(x, y1, 1)
-ax2.set_ylabel('between y1 and 1')
-
-ax3.fill_between(x, y1, y2)
-ax3.set_ylabel('between y1 and y2')
-ax3.set_xlabel('x')
-
-# now fill between y1 and y2 where a logical condition is met. Note
-# this is different than calling
-# fill_between(x[where], y1[where],y2[where]
-# because of edge effects over multiple contiguous regions.
-fig = figure()
-ax = fig.add_subplot(211)
-ax.plot(x, y1, x, y2, color='black')
-ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
-ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
-ax.set_title('fill between where')
-
-# Test support for masked arrays.
-y2 = np.ma.masked_greater(y2, 1.0)
-ax1 = fig.add_subplot(212, sharex=ax)
-ax1.plot(x, y1, x, y2, color='black')
-ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
-ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
-ax1.set_title('Now regions with y2>1 are masked')
-
-# This example illustrates a problem; because of the data
-# gridding, there are undesired unfilled triangles at the crossover
-# points. A brute-force solution would be to interpolate all
-# arrays to a very fine grid before plotting.
-
-# show how to use transforms to create axes spans where a certain condition is satisfied
-fig = figure()
-ax = fig.add_subplot(111)
-y = np.sin(4*np.pi*x)
-ax.plot(x, y, color='black')
-
-# use the data coordinates for the x-axis and the axes coordinates for the y-axis
-import matplotlib.transforms as mtransforms
-trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
-theta = 0.9
-ax.axhline(theta, color='green', lw=2, alpha=0.5)
-ax.axhline(-theta, color='red', lw=2, alpha=0.5)
-ax.fill_between(x, 0, 1, where=y>theta, facecolor='green', alpha=0.5, transform=trans)
-ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans)
-
-
-
-show()
-
Copied: trunk/matplotlib/examples/pylab_examples/fill_between_demo.py (from rev 7180, trunk/matplotlib/examples/pylab_examples/fill_between.py)
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_between_demo.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/fill_between_demo.py 2009-06-05 16:53:11 UTC (rev 7181)
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+import matplotlib.mlab as mlab
+from matplotlib.pyplot import figure, show
+import numpy as np
+
+x = np.arange(0.0, 2, 0.01)
+y1 = np.sin(2*np.pi*x)
+y2 = 1.2*np.sin(4*np.pi*x)
+
+fig = figure()
+ax1 = fig.add_subplot(311)
+ax2 = fig.add_subplot(312, sharex=ax1)
+ax3 = fig.add_subplot(313, sharex=ax1)
+
+ax1.fill_between(x, 0, y1)
+ax1.set_ylabel('between y1 and 0')
+
+ax2.fill_between(x, y1, 1)
+ax2.set_ylabel('between y1 and 1')
+
+ax3.fill_between(x, y1, y2)
+ax3.set_ylabel('between y1 and y2')
+ax3.set_xlabel('x')
+
+# now fill between y1 and y2 where a logical condition is met. Note
+# this is different than calling
+# fill_between(x[where], y1[where],y2[where]
+# because of edge effects over multiple contiguous regions.
+fig = figure()
+ax = fig.add_subplot(211)
+ax.plot(x, y1, x, y2, color='black')
+ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
+ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
+ax.set_title('fill between where')
+
+# Test support for masked arrays.
+y2 = np.ma.masked_greater(y2, 1.0)
+ax1 = fig.add_subplot(212, sharex=ax)
+ax1.plot(x, y1, x, y2, color='black')
+ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
+ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
+ax1.set_title('Now regions with y2>1 are masked')
+
+# This example illustrates a problem; because of the data
+# gridding, there are undesired unfilled triangles at the crossover
+# points. A brute-force solution would be to interpolate all
+# arrays to a very fine grid before plotting.
+
+# show how to use transforms to create axes spans where a certain condition is satisfied
+fig = figure()
+ax = fig.add_subplot(111)
+y = np.sin(4*np.pi*x)
+ax.plot(x, y, color='black')
+
+# use the data coordinates for the x-axis and the axes coordinates for the y-axis
+import matplotlib.transforms as mtransforms
+trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
+theta = 0.9
+ax.axhline(theta, color='green', lw=2, alpha=0.5)
+ax.axhline(-theta, color='red', lw=2, alpha=0.5)
+ax.fill_between(x, 0, 1, where=y>theta, facecolor='green', alpha=0.5, transform=trans)
+ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans)
+
+
+
+show()
+
Deleted: trunk/matplotlib/examples/pylab_examples/fill_betweenx.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_betweenx.py 2009-06-05 16:51:21 UTC (rev 7180)
+++ trunk/matplotlib/examples/pylab_examples/fill_betweenx.py 2009-06-05 16:53:11 UTC (rev 7181)
@@ -1,50 +0,0 @@
-import matplotlib.mlab as mlab
-from matplotlib.pyplot import figure, show
-import numpy as np
-
-## Copy of fill_between.py but using fill_betweenx() instead.
-
-x = np.arange(0.0, 2, 0.01)
-y1 = np.sin(2*np.pi*x)
-y2 = 1.2*np.sin(4*np.pi*x)
-
-fig = figure()
-ax1 = fig.add_subplot(311)
-ax2 = fig.add_subplot(312, sharex=ax1)
-ax3 = fig.add_subplot(313, sharex=ax1)
-
-ax1.fill_betweenx(x, 0, y1)
-ax1.set_ylabel('between y1 and 0')
-
-ax2.fill_betweenx(x, y1, 1)
-ax2.set_ylabel('between y1 and 1')
-
-ax3.fill_betweenx(x, y1, y2)
-ax3.set_ylabel('between y1 and y2')
-ax3.set_xlabel('x')
-
-# now fill between y1 and y2 where a logical condition is met. Note
-# this is different than calling
-# fill_between(x[where], y1[where],y2[where]
-# because of edge effects over multiple contiguous regions.
-fig = figure()
-ax = fig.add_subplot(211)
-ax.plot(y1, x, y2, x, color='black')
-ax.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green')
-ax.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red')
-ax.set_title('fill between where')
-
-# Test support for masked arrays.
-y2 = np.ma.masked_greater(y2, 1.0)
-ax1 = fig.add_subplot(212, sharex=ax)
-ax1.plot(y1, x, y2, x, color='black')
-ax1.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green')
-ax1.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red')
-ax1.set_title('Now regions with y2 > 1 are masked')
-
-# This example illustrates a problem; because of the data
-# gridding, there are undesired unfilled triangles at the crossover
-# points. A brute-force solution would be to interpolate all
-# arrays to a very fine grid before plotting.
-
-show()
Copied: trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py (from rev 7178, trunk/matplotlib/examples/pylab_examples/fill_betweenx.py)
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py 2009-06-05 16:53:11 UTC (rev 7181)
@@ -0,0 +1,50 @@
+import matplotlib.mlab as mlab
+from matplotlib.pyplot import figure, show
+import numpy as np
+
+## Copy of fill_between.py but using fill_betweenx() instead.
+
+x = np.arange(0.0, 2, 0.01)
+y1 = np.sin(2*np.pi*x)
+y2 = 1.2*np.sin(4*np.pi*x)
+
+fig = figure()
+ax1 = fig.add_subplot(311)
+ax2 = fig.add_subplot(312, sharex=ax1)
+ax3 = fig.add_subplot(313, sharex=ax1)
+
+ax1.fill_betweenx(x, 0, y1)
+ax1.set_ylabel('between y1 and 0')
+
+ax2.fill_betweenx(x, y1, 1)
+ax2.set_ylabel('between y1 and 1')
+
+ax3.fill_betweenx(x, y1, y2)
+ax3.set_ylabel('between y1 and y2')
+ax3.set_xlabel('x')
+
+# now fill between y1 and y2 where a logical condition is met. Note
+# this is different than calling
+# fill_between(x[where], y1[where],y2[where]
+# because of edge effects over multiple contiguous regions.
+fig = figure()
+ax = fig.add_subplot(211)
+ax.plot(y1, x, y2, x, color='black')
+ax.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green')
+ax.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red')
+ax.set_title('fill between where')
+
+# Test support for masked arrays.
+y2 = np.ma.masked_greater(y2, 1.0)
+ax1 = fig.add_subplot(212, sharex=ax)
+ax1.plot(y1, x, y2, x, color='black')
+ax1.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green')
+ax1.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red')
+ax1.set_title('Now regions with y2 > 1 are masked')
+
+# This example illustrates a problem; because of the data
+# gridding, there are undesired unfilled triangles at the crossover
+# points. A brute-force solution would be to interpolate all
+# arrays to a very fine grid before plotting.
+
+show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-05 16:51:27
|
Revision: 7180
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7180&view=rev
Author: jdh2358
Date: 2009-06-05 16:51:21 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
added example to fill_between to show how to create multiple axes spans where a condition is true
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/fill_between.py
Modified: trunk/matplotlib/examples/pylab_examples/fill_between.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:49:29 UTC (rev 7179)
+++ trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:51:21 UTC (rev 7180)
@@ -55,10 +55,11 @@
# use the data coordinates for the x-axis and the axes coordinates for the y-axis
import matplotlib.transforms as mtransforms
trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
-ax.axhline(0.5, color='green', lw=2, alpha=0.5)
-ax.axhline(-0.5, color='red', lw=2, alpha=0.5)
-ax.fill_between(x, 0, 1, where=y2>0.5, facecolor='green', alpha=0.5, transform=trans)
-ax.fill_between(x, 0, 1, where=y2<-0.5, facecolor='red', alpha=0.5, transform=trans)
+theta = 0.9
+ax.axhline(theta, color='green', lw=2, alpha=0.5)
+ax.axhline(-theta, color='red', lw=2, alpha=0.5)
+ax.fill_between(x, 0, 1, where=y>theta, facecolor='green', alpha=0.5, transform=trans)
+ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-05 16:49:32
|
Revision: 7179
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7179&view=rev
Author: jdh2358
Date: 2009-06-05 16:49:29 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
added example to fill_between to show how to create multiple axes spans where a condition is true
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/fill_between.py
Modified: trunk/matplotlib/examples/pylab_examples/fill_between.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 13:00:47 UTC (rev 7178)
+++ trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:49:29 UTC (rev 7179)
@@ -46,5 +46,21 @@
# points. A brute-force solution would be to interpolate all
# arrays to a very fine grid before plotting.
+# show how to use transforms to create axes spans where a certain condition is satisfied
+fig = figure()
+ax = fig.add_subplot(111)
+y = np.sin(4*np.pi*x)
+ax.plot(x, y, color='black')
+
+# use the data coordinates for the x-axis and the axes coordinates for the y-axis
+import matplotlib.transforms as mtransforms
+trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
+ax.axhline(0.5, color='green', lw=2, alpha=0.5)
+ax.axhline(-0.5, color='red', lw=2, alpha=0.5)
+ax.fill_between(x, 0, 1, where=y2>0.5, facecolor='green', alpha=0.5, transform=trans)
+ax.fill_between(x, 0, 1, where=y2<-0.5, facecolor='red', alpha=0.5, transform=trans)
+
+
+
show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-05 13:00:49
|
Revision: 7178
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7178&view=rev
Author: jdh2358
Date: 2009-06-05 13:00:47 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
added JJ's F/C two scale example
Added Paths:
-----------
trunk/matplotlib/examples/api/fahrenheit_celcius_scales.py
Added: trunk/matplotlib/examples/api/fahrenheit_celcius_scales.py
===================================================================
--- trunk/matplotlib/examples/api/fahrenheit_celcius_scales.py (rev 0)
+++ trunk/matplotlib/examples/api/fahrenheit_celcius_scales.py 2009-06-05 13:00:47 UTC (rev 7178)
@@ -0,0 +1,28 @@
+"""
+Shoiw how to display two scales on the left and right y axis -- Fahrenheit and Celcius
+"""
+
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax1 = fig.add_subplot(111) # the Fahrenheit scale
+ax2 = ax1.twinx() # the Celcius scale
+
+def Tc(Tf):
+ return (5./9.)*(Tf-32)
+
+
+def update_ax2(ax1):
+ y1, y2 = ax1.get_ylim()
+ ax2.set_ylim(Tc(y1), Tc(y2))
+ ax2.figure.canvas.draw()
+
+# automatically update ylim of ax2 when ylim of ax1 changes.
+ax1.callbacks.connect("ylim_changed", update_ax2)
+ax1.plot([78, 79, 79, 77])
+
+ax1.set_title('Two scales: Fahrenheit and Celcius')
+ax1.set_ylabel('Fahrenheit')
+ax2.set_ylabel('Celcius')
+
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-06-03 12:50:23
|
Revision: 7176
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7176&view=rev
Author: mdboom
Date: 2009-06-03 12:15:06 +0000 (Wed, 03 Jun 2009)
Log Message:
-----------
Bugfix in FltkAgg backend, thanks to Daniel
Modified Paths:
--------------
branches/v0_98_5_maint/lib/matplotlib/backends/backend_fltkagg.py
Modified: branches/v0_98_5_maint/lib/matplotlib/backends/backend_fltkagg.py
===================================================================
--- branches/v0_98_5_maint/lib/matplotlib/backends/backend_fltkagg.py 2009-06-03 05:49:59 UTC (rev 7175)
+++ branches/v0_98_5_maint/lib/matplotlib/backends/backend_fltkagg.py 2009-06-03 12:15:06 UTC (rev 7176)
@@ -115,6 +115,7 @@
window = Fltk.Fl_Double_Window(10,10,30,30)
canvas = FigureCanvasFltkAgg(figure)
window.end()
+ #Fltk.Fl.visual(Fltk.FL_DOUBLE)
window.show()
window.make_current()
figManager = FigureManagerFltkAgg(canvas, num, window)
@@ -157,7 +158,7 @@
def handle(self, event):
x=Fltk.Fl.event_x()
y=Fltk.Fl.event_y()
- yf=self._source.figure.bbox.height() - y
+ yf=self._source.figure.bbox.height - y
if event == Fltk.FL_FOCUS or event == Fltk.FL_UNFOCUS:
return 1
elif event == Fltk.FL_KEYDOWN:
@@ -230,7 +231,7 @@
def resize(self,size):
w, h = size
# compute desired figure size in inches
- dpival = self.figure.dpi.get()
+ dpival = self.figure.dpi
winch = w/dpival
hinch = h/dpival
self.figure.set_size_inches(winch,hinch)
@@ -405,7 +406,7 @@
"""
def __init__(self, canvas, figman):
- #xmin, xmax = canvas.figure.bbox.intervalx().get_bounds()
+ #xmin, xmax = canvas.figure.bbox.intervalx
#height, width = 50, xmax-xmin
self.canvas = canvas
self.figman = figman
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-06-03 12:50:19
|
Revision: 7177
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7177&view=rev
Author: mdboom
Date: 2009-06-03 12:16:21 +0000 (Wed, 03 Jun 2009)
Log Message:
-----------
Merged revisions 7176 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_98_5_maint
........
r7176 | mdboom | 2009-06-03 08:15:06 -0400 (Wed, 03 Jun 2009) | 1 line
Bugfix in FltkAgg backend, thanks to Daniel
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py
Property Changed:
----------------
trunk/matplotlib/
trunk/matplotlib/doc/pyplots/README
trunk/matplotlib/doc/sphinxext/gen_gallery.py
trunk/matplotlib/doc/sphinxext/gen_rst.py
trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py
trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py
trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7115
+ /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7176
Modified: svn:mergeinfo
- /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
+ /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176
Property changes on: trunk/matplotlib/doc/pyplots/README
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
+ /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176
Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
+ /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176
Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
+ /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2009-06-03 12:15:06 UTC (rev 7176)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2009-06-03 12:16:21 UTC (rev 7177)
@@ -115,6 +115,7 @@
window = Fltk.Fl_Double_Window(10,10,30,30)
canvas = FigureCanvasFltkAgg(figure)
window.end()
+ #Fltk.Fl.visual(Fltk.FL_DOUBLE)
window.show()
window.make_current()
figManager = FigureManagerFltkAgg(canvas, num, window)
@@ -157,7 +158,7 @@
def handle(self, event):
x=Fltk.Fl.event_x()
y=Fltk.Fl.event_y()
- yf=self._source.figure.bbox.height() - y
+ yf=self._source.figure.bbox.height - y
if event == Fltk.FL_FOCUS or event == Fltk.FL_UNFOCUS:
return 1
elif event == Fltk.FL_KEYDOWN:
@@ -230,7 +231,7 @@
def resize(self,size):
w, h = size
# compute desired figure size in inches
- dpival = self.figure.dpi.get()
+ dpival = self.figure.dpi
winch = w/dpival
hinch = h/dpival
self.figure.set_size_inches(winch,hinch)
@@ -405,7 +406,7 @@
"""
def __init__(self, canvas, figman):
- #xmin, xmax = canvas.figure.bbox.intervalx().get_bounds()
+ #xmin, xmax = canvas.figure.bbox.intervalx
#height, width = 50, xmax-xmin
self.canvas = canvas
self.figman = figman
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
+ /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
+ /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
+ /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-06-03 05:50:06
|
Revision: 7175
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7175&view=rev
Author: leejjoon
Date: 2009-06-03 05:49:59 +0000 (Wed, 03 Jun 2009)
Log Message:
-----------
axes_grid: initial checkin of curvelinear grid support
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/mpl_toolkits/axes_grid/ChangeLog
trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py
Added Paths:
-----------
trunk/matplotlib/examples/axes_grid/demo_curvelinear_grid.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/angle_helper.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/clip_path.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_finder.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-06-02 02:30:57 UTC (rev 7174)
+++ trunk/matplotlib/CHANGELOG 2009-06-03 05:49:59 UTC (rev 7175)
@@ -1,3 +1,6 @@
+2009-06-03 axes_grid : Initial check-in of curvelinear grid support. See
+ examples/axes_grid/demo_curvelinear_grid.py - JJL
+
2009-06-01 Spine is now derived from Patch - ADS
2009-06-01 use cbook.is_string_like() instead of isinstance() for spines - ADS
Added: trunk/matplotlib/examples/axes_grid/demo_curvelinear_grid.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/demo_curvelinear_grid.py (rev 0)
+++ trunk/matplotlib/examples/axes_grid/demo_curvelinear_grid.py 2009-06-03 05:49:59 UTC (rev 7175)
@@ -0,0 +1,131 @@
+import numpy as np
+#from matplotlib.path import Path
+
+import matplotlib.pyplot as plt
+import matplotlib.cbook as cbook
+
+from mpl_toolkits.axes_grid.grid_helper_curvelinear import GridHelperCurveLinear
+from mpl_toolkits.axes_grid.axislines import Subplot
+
+from mpl_toolkits.axes_grid.parasite_axes import SubplotHost, \
+ ParasiteAxesAuxTrans
+
+
+def curvelinear_test1(fig):
+ """
+ grid for custom transform.
+ """
+
+ def tr(x, y):
+ x, y = np.asarray(x), np.asarray(y)
+ return x, y-x
+
+ def inv_tr(x,y):
+ x, y = np.asarray(x), np.asarray(y)
+ return x, y+x
+
+
+ grid_helper = GridHelperCurveLinear((tr, inv_tr))
+
+ ax1 = Subplot(fig, 1, 2, 1, grid_helper=grid_helper)
+ # ax1 will have a ticks and gridlines defined by the given
+ # transform (+ transData of the Axes). Note that the transform of
+ # the Axes itself (i.e., transData) is not affected by the given
+ # transform.
+
+ fig.add_subplot(ax1)
+
+ xx, yy = tr([3, 6], [5.0, 10.])
+ ax1.plot(xx, yy)
+
+ ax1.set_aspect(1.)
+ ax1.set_xlim(0, 10.)
+ ax1.set_ylim(0, 10.)
+
+ ax1.grid(True)
+
+
+
+import mpl_toolkits.axes_grid.angle_helper as angle_helper
+from matplotlib.projections import PolarAxes
+from matplotlib.transforms import Affine2D
+
+def curvelinear_test2(fig):
+ """
+ polar projection, but in a rectangular box.
+ """
+
+ # PolarAxes.PolarTransform takes radian. However, we want our coordinate
+ # system in degree
+ tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
+
+ # polar projection, which involves cycle, and also has limits in
+ # its coordinates, needs a special method to find the extremes
+ # (min, max of the coordinate within the view).
+
+ # 20, 20 : number of sampling points along x, y direction
+ extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
+ lon_cycle = 360,
+ lat_cycle = None,
+ lon_minmax = None,
+ lat_minmax = (0, np.inf),
+ )
+
+ grid_locator1 = angle_helper.LocatorDMS(12)
+ # Find a grid values appropriate for the coordinate (degree,
+ # minute, second).
+
+ tick_formatter1 = angle_helper.FormatterDMS()
+ # And also uses an appropriate formatter. Note that,the
+ # acceptable Locator and Formatter class is a bit different than
+ # that of mpl's, and you cannot directly use mpl's Locator and
+ # Formatter here (but may be possible in the future).
+
+ grid_helper = GridHelperCurveLinear(tr,
+ extreme_finder=extreme_finder,
+ grid_locator1=grid_locator1,
+ tick_formatter1=tick_formatter1
+ )
+
+
+ ax1 = SubplotHost(fig, 1, 2, 2, grid_helper=grid_helper)
+
+ # make ticklabels of right and top axis visible.
+ ax1.axis["right"].major_ticklabels.set_visible(True)
+ ax1.axis["top"].major_ticklabels.set_visible(True)
+
+ # let right axis shows ticklabels for 1st coordinate (angle)
+ ax1.axis["right"].get_helper().nth_coord_ticks=0
+ # let bottom axis shows ticklabels for 2nd coordinate (radius)
+ ax1.axis["bottom"].get_helper().nth_coord_ticks=1
+
+ fig.add_subplot(ax1)
+
+
+ # A parasite axes with given transform
+ ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
+ # note that ax2.transData == tr + ax1.transData
+ # Anthing you draw in ax2 will match the ticks and grids of ax1.
+ ax1.parasites.append(ax2)
+ intp = cbook.simple_linear_interpolation
+ ax2.plot(intp(np.array([0, 30]), 50),
+ intp(np.array([10., 10.]), 50))
+
+ ax1.set_aspect(1.)
+ ax1.set_xlim(-5, 12)
+ ax1.set_ylim(-5, 10)
+
+ ax1.grid(True)
+
+if 1:
+ fig = plt.figure(1, figsize=(7, 4))
+ fig.clf()
+
+ curvelinear_test1(fig)
+ curvelinear_test2(fig)
+
+ plt.draw()
+ plt.show()
+
+
+
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/ChangeLog
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/ChangeLog 2009-06-02 02:30:57 UTC (rev 7174)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/ChangeLog 2009-06-03 05:49:59 UTC (rev 7175)
@@ -1,6 +1,7 @@
2009-06-01 Jae-Joon Lee <lee...@gm...>
* axislines.py (Axes.toggle_axisline): fix broken spine support.
+ (AxisArtistHelper): Initial support for curvelinear grid and ticks.
2009-05-04 Jae-Joon Lee <lee...@gm...>
Added: trunk/matplotlib/lib/mpl_toolkits/axes_grid/angle_helper.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/angle_helper.py (rev 0)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/angle_helper.py 2009-06-03 05:49:59 UTC (rev 7175)
@@ -0,0 +1,345 @@
+from math import floor
+
+import numpy as np
+import math
+
+A = np.array
+
+from mpl_toolkits.axes_grid.grid_finder import ExtremeFinderSimple
+
+def select_step_degree(dv):
+
+ degree_limits_ = [1.5, 3, 7, 13, 20, 40, 70, 120, 270, 520]
+ degree_steps_ = [ 1, 2, 5, 10, 15, 30, 45, 90, 180, 360]
+ degree_factors = [1.] * len(degree_steps_)
+
+ minsec_limits_ = [1.5, 2.5, 3.5, 8, 11, 18, 25, 45]
+ minsec_steps_ = [1, 2, 3, 5, 10, 15, 20, 30]
+
+ minute_limits_ = A(minsec_limits_)*(1./60.)
+ minute_factors = [60.] * len(minute_limits_)
+
+ second_limits_ = A(minsec_limits_)*(1./3600.)
+ second_factors = [3600.] * len(second_limits_)
+
+ degree_limits = np.concatenate([second_limits_,
+ minute_limits_,
+ degree_limits_])
+
+ degree_steps = np.concatenate([minsec_steps_,
+ minsec_steps_,
+ degree_steps_])
+
+ degree_factors = np.concatenate([second_factors,
+ minute_factors,
+ degree_factors])
+
+ n = degree_limits.searchsorted(dv)
+ step = degree_steps[n]
+ factor = degree_factors[n]
+
+ return step, factor
+
+
+
+def select_step_hour(dv):
+
+ hour_limits_ = [1.5, 2.5, 3.5, 5, 7, 10, 15, 21, 36]
+ hour_steps_ = [1, 2 , 3, 4, 6, 8, 12, 18, 24]
+ hour_factors = [1.] * len(hour_steps_)
+
+ minsec_limits_ = [1.5, 2.5, 3.5, 4.5, 5.5, 8, 11, 14, 18, 25, 45]
+ minsec_steps_ = [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30]
+
+ minute_limits_ = A(minsec_limits_)*(1./60.)
+ minute_factors = [60.] * len(minute_limits_)
+
+ second_limits_ = A(minsec_limits_)*(1./3600.)
+ second_factors = [3600.] * len(second_limits_)
+
+ hour_limits = np.concatenate([second_limits_,
+ minute_limits_,
+ hour_limits_])
+
+ hour_steps = np.concatenate([minsec_steps_,
+ minsec_steps_,
+ hour_steps_])
+
+ hour_factors = np.concatenate([second_factors,
+ minute_factors,
+ hour_factors])
+
+ n = hour_limits.searchsorted(dv)
+ step = hour_steps[n]
+ factor = hour_factors[n]
+
+ return step, factor
+
+
+def select_step_sub(dv):
+
+ # subarcsec or degree
+ tmp = 10.**(int(math.log10(dv))-1.)
+ dv2 = dv/tmp
+ substep_limits_ = [1.5, 3., 7.]
+ substep_steps_ = [1. , 2., 5.]
+
+ factor = 1./tmp
+
+ if 1.5*tmp >= dv:
+ step = 1
+ elif 3.*tmp >= dv:
+ step = 2
+ elif 7.*tmp >= dv:
+ step = 5
+ else:
+ step = 1
+ factor = 0.1*factor
+
+ return step, factor
+
+
+def select_step(v1, v2, nv, hour=False):
+
+ if v1 > v2:
+ v1, v2 = v2, v1
+
+ A = np.array
+
+ dv = float(v2 - v1) / nv
+
+ if hour:
+ _select_step = select_step_hour
+ cycle = 24.
+ else:
+ _select_step = select_step_degree
+ cycle = 360.
+
+ # for degree
+ if dv > 1./3600.:
+ #print "degree"
+ step, factor = _select_step(dv)
+ else:
+ step, factor = select_step_sub(dv*3600.)
+ #print "feac", step, factor
+
+ factor = factor * 3600.
+
+
+ f1, f2, fstep = v1*factor, v2*factor, step/factor
+ levs = np.arange(math.floor(f1/step), math.ceil(f2/step)+0.5,
+ 1, dtype="i") * step
+
+ # n : number valid levels. If there is a cycle, e.g., [0, 90, 180,
+ # 270, 360], the a grid line needs to be extend from 0 to 360, so
+ # we need to return the whole array. However, the last level (360)
+ # needs to be ignored often. In this case, so we return n=4.
+
+ n = len(levs)
+
+
+ # we need to check the range of values
+ # for example, -90 to 90, 0 to 360,
+
+
+ if factor == 1. and (levs[-1] >= levs[0]+cycle): # check for cycle
+ nv = int(cycle / step)
+ levs = np.arange(0, nv, 1) * step
+ n = len(levs)
+
+ return levs, n, factor
+
+
+def select_step24(v1, v2, nv):
+ v1, v2 = v1/15., v2/15.
+ levs, n, factor = select_step(v1, v2, nv, hour=True)
+ return levs*15., n, factor
+
+def select_step360(v1, v2, nv):
+ return select_step(v1, v2, nv, hour=False)
+
+
+
+
+class LocatorHMS(object):
+ def __init__(self, den):
+ self.den = den
+ def __call__(self, v1, v2):
+ return select_step24(v1, v2, self.den)
+
+
+class LocatorDMS(object):
+ def __init__(self, den):
+ self.den = den
+ def __call__(self, v1, v2):
+ return select_step360(v1, v2, self.den)
+
+
+class FormatterHMS(object):
+ def __call__(self, direction, factor, values): # hour
+ if len(values) == 0:
+ return []
+ ss = [[-1, 1][v>0] for v in values]
+ values = np.abs(values)/15.
+
+ if factor == 1:
+ return ["$%d^{\mathrm{h}}$" % (int(v),) for v in values]
+ elif factor == 60:
+ return ["$%d^{\mathrm{h}}\,%02d^{\mathrm{m}}$" % (s*floor(v/60.), v%60) \
+ for s, v in zip(ss, values)]
+ elif factor == 3600:
+ if ss[-1] == -1:
+ inverse_order = True
+ values = values[::-1]
+ else:
+ inverse_order = False
+ degree = floor(values[0]/3600.)
+ hm_fmt = "$%d^{\mathrm{h}}\,%02d^{\mathrm{m}}\,"
+ s_fmt = "%02d^{\mathrm{s}}$"
+ l_hm_old = ""
+ r = []
+ for v in values-3600*degree:
+ l_hm = hm_fmt % (ss[0]*degree, floor(v/60.))
+ l_s = s_fmt % (v%60,)
+ if l_hm != l_hm_old:
+ l_hm_old = l_hm
+ l = l_hm + l_s
+ else:
+ l = "$"+l_s
+ r.append(l)
+ if inverse_order:
+ return r[::-1]
+ else:
+ return r
+ #return [fmt % (ss[0]*degree, floor(v/60.), v%60) \
+ # for s, v in zip(ss, values-3600*degree)]
+ else: # factor > 3600.
+ return ["$%s$" % (str(v),) for v in values]
+
+
+class FormatterDMS(object):
+ def __call__(self, direction, factor, values):
+ if len(values) == 0:
+ return []
+ ss = [[-1, 1][v>0] for v in values]
+ values = np.abs(values)
+ if factor == 1:
+ return ["$%d^{\circ}$" % (s*int(v),) for (s, v) in zip(ss, values)]
+ elif factor == 60:
+ return ["$%d^{\circ}\,%02d^{\prime}$" % (s*floor(v/60.), v%60) \
+ for s, v in zip(ss, values)]
+ elif factor == 3600:
+ if ss[-1] == -1:
+ inverse_order = True
+ values = values[::-1]
+ else:
+ inverse_order = False
+ degree = floor(values[0]/3600.)
+ hm_fmt = "$%d^{\circ}\,%02d^{\prime}\,"
+ s_fmt = "%02d^{\prime\prime}$"
+ l_hm_old = ""
+ r = []
+ for v in values-3600*degree:
+ l_hm = hm_fmt % (ss[0]*degree, floor(v/60.))
+ l_s = s_fmt % (v%60,)
+ if l_hm != l_hm_old:
+ l_hm_old = l_hm
+ l = l_hm + l_s
+ else:
+ l = "$"+l_s
+ r.append(l)
+ if inverse_order:
+ return r[::-1]
+ else:
+ return r
+ #return [fmt % (ss[0]*degree, floor(v/60.), v%60) \
+ # for s, v in zip(ss, values-3600*degree)]
+ else: # factor > 3600.
+ return ["$%s$" % (str(v),) for v in ss*values]
+
+
+
+
+class ExtremeFinderCycle(ExtremeFinderSimple):
+ """
+ When there is a cycle, e.g., longitude goes from 0-360.
+ """
+ def __init__(self,
+ nx, ny,
+ lon_cycle = 360.,
+ lat_cycle = None,
+ lon_minmax = None,
+ lat_minmax = (-90, 90)
+ ):
+ #self.transfrom_xy = transform_xy
+ #self.inv_transfrom_xy = inv_transform_xy
+ self.nx, self.ny = nx, ny
+ self.lon_cycle, self.lat_cycle = lon_cycle, lat_cycle
+ self.lon_minmax = lon_minmax
+ self.lat_minmax = lat_minmax
+
+
+ def __call__(self, transform_xy, x1, y1, x2, y2):
+ """
+ get extreme values.
+
+ x1, y1, x2, y2 in image coordinates (0-based)
+ nx, ny : number of dvision in each axis
+ """
+ x_, y_ = np.linspace(x1, x2, self.nx), np.linspace(y1, y2, self.ny)
+ x, y = np.meshgrid(x_, y_)
+ lon, lat = transform_xy(np.ravel(x), np.ravel(y))
+
+ # iron out jumps, but algorithm should be improved.
+ # Tis is just naive way of doing and my fail for some cases.
+ if self.lon_cycle is not None:
+ lon0 = lon.min()
+ lon -= 360. * ((lon - lon0) > 180.)
+ if self.lat_cycle is not None:
+ lat0 = lat.min()
+ lat -= 360. * ((lat - lat0) > 180.)
+
+ lon_min, lon_max = lon.min(), lon.max()
+ lat_min, lat_max = lat.min(), lat.max()
+
+ lon_min, lon_max, lat_min, lat_max = \
+ self._adjust_extremes(lon_min, lon_max, lat_min, lat_max)
+
+ return lon_min, lon_max, lat_min, lat_max
+
+
+ def _adjust_extremes(self, lon_min, lon_max, lat_min, lat_max):
+
+ lon_min, lon_max, lat_min, lat_max = \
+ self._add_pad(lon_min, lon_max, lat_min, lat_max)
+
+ # check cycle
+ if self.lon_cycle:
+ lon_max = min(lon_max, lon_min + self.lon_cycle)
+ if self.lat_cycle:
+ lat_max = min(lat_max, lat_min + self.lat_cycle)
+
+ if self.lon_minmax is not None:
+ min0 = self.lon_minmax[0]
+ lon_min = max(min0, lon_min)
+ max0 = self.lon_minmax[1]
+ lon_max = min(max0, lon_max)
+
+ if self.lat_minmax is not None:
+ min0 = self.lat_minmax[0]
+ lat_min = max(min0, lat_min)
+ max0 = self.lat_minmax[1]
+ lat_max = min(max0, lat_max)
+
+ return lon_min, lon_max, lat_min, lat_max
+
+
+
+
+
+if __name__ == "__main__":
+ #test2()
+ print select_step360(21.2, 33.3, 5)
+ print select_step360(20+21.2/60., 21+33.3/60., 5)
+ print select_step360(20.5+21.2/3600., 20.5+33.3/3600., 5)
+ print select_step360(20+21.2/60., 20+53.3/60., 5)
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py 2009-06-02 02:30:57 UTC (rev 7174)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py 2009-06-03 05:49:59 UTC (rev 7175)
@@ -1,3 +1,48 @@
+"""
+Axislines includes modified implementation of the Axes class. The
+biggest difference is that the artists responsible to draw axis line,
+ticks, ticklabel and axis labels are separated out from the mpl's Axis
+class, which are much more than artists in the original
+mpl. Originally, this change was motivated to support curvlinear
+grid. Here are a few reasons that I came up with new axes class.
+
+
+ * "top" and "bottom" x-axis (or "left" and "right" y-axis) can have
+ different ticks (tick locations and labels). This is not possible
+ with the current mpl, although some twin axes trick can help.
+
+ * Curvelinear grid.
+
+ * angled ticks.
+
+In the new axes class, xaxis and yaxis is set to not visible by
+default, and new set of artist (AxisArtist) are defined to draw axis
+line, ticks, ticklabels and axis label. Axes.axis attribute serves as
+a dictionary of these artists, i.e., ax.axis["left"] is a AxisArtist
+instance responsible to draw left y-axis. The default Axes.axis contains
+"bottom", "left", "top" and "right".
+
+AxisArtist can be considered as a container artist and
+has following children artists which will draw ticks, labels, etc.
+
+ * line
+ * major_ticks, major_ticklabels
+ * minor_ticks, minor_ticklabels
+ * offsetText
+ * label
+
+Note that these are separate artists from Axis class of the
+original mpl, thus most of tick-related command in the original mpl
+won't work, although some effort has made to work with. For example,
+color and markerwidth of the ax.axis["bottom"].major_ticks will follow
+those of Axes.xaxis unless explicitly specified.
+
+In addition to AxisArtist, the Axes will have *gridlines* attribute,
+which obviously draws grid lines. The gridlines needs to be separated
+from the axis as some gridlines can never pass any axis.
+
+"""
+
import matplotlib.axes as maxes
import matplotlib.artist as martist
import matplotlib.text as mtext
@@ -73,25 +118,92 @@
class UnimplementedException(Exception):
pass
-class AxisLineHelper(object):
+
+
+class AxisArtistHelper(object):
+ """
+ AxisArtistHelper should define
+ following method with given APIs. Note that the first axes argument
+ will be axes attribute of the caller artist.
+
+
+ # LINE
+
+ def get_line(self, axes):
+ # path : Path
+ return path
+
+ def get_line_transform(self, axes):
+ # ...
+ # trans : transform
+ return trans
+
+ # LABEL
+
+ def get_label_pos(self, axes):
+ # x, y : position
+ return (x, y), trans
+
+
+ def get_label_offset_transform(self, \
+ axes,
+ pad_points, fontprops, renderer,
+ bboxes,
+ ):
+ # va : vertical alignment
+ # ha : horizontal alignment
+ # a : angle
+ return trans, va, ha, a
+
+ # TICK
+
+ def get_tick_transform(self, axes):
+ return trans
+
+ def get_tick_iterators(self, axes):
+ # iter : iteratoable object that yields (c, angle, l) where
+ # c, angle, l is position, tick angle, and label
+
+ return iter_major, iter_minot
+
+
+ """
class _Base(object):
+
def __init__(self, label_direction):
self.label_direction = label_direction
- def get_label_pos(self):
- raise UnimplementedException("")
+ #def update(self):
+ # raise UnimplementedException("update method not implemented")
+ def update_lim(self, axes):
+ pass
+
_label_angles = dict(left=90, right=90, bottom=0, top=0)
_ticklabel_angles = dict(left=0, right=0, bottom=0, top=0)
- def _get_label_transform(self, pad_points, fontprops, renderer,
- bboxes=None,
- trans=None):
+ def _get_label_offset_transform(self, pad_points, fontprops, renderer,
+ bboxes=None,
+ #trans=None
+ ):
- if trans is None:
- trans = self.axes.transAxes
+ """
+ Returns (offset-transform, vertical-alignment, horiz-alignment)
+ of (tick or axis) labels appropriate for the label
+ direction.
- #dpi_scale_trans = self.axes.figure.dpi_scale_trans
+ The offset-transform represents a required pixel offset
+ from the reference point. For example, x-axis center will
+ be the referece point for xlabel.
+
+ pad_points : padding from axis line or tick labels (see bboxes)
+ fontprops : font properties for label
+ renderer : renderer
+ bboxes=None : list of bboxes (window extents) of the tick labels.
+
+ all the above parameters are used to estimate the offset.
+
+ """
if renderer:
pad_pixels = renderer.points_to_pixels(pad_points)
font_size_points = fontprops.get_size_in_points()
@@ -111,74 +223,64 @@
tr = Affine2D()
if self.label_direction == "left":
tr.translate(-(pad_pixels+w), 0.)
- trans = trans + tr
+ #trans = trans + tr
- return trans, "center", "right"
+ return tr, "center", "right"
elif self.label_direction == "right":
tr.translate(+(pad_pixels+w), 0.)
- #tr = ScaledTranslation(+((pad_points+w) / 72.), 0.,
- # dpi_scale_trans)
- trans = trans + tr
+ #trans = trans + tr
- return trans, "center", "left"
+ return tr, "center", "left"
elif self.label_direction == "bottom":
- #pad_points = font_size_points + pad_points
tr.translate(0, -(pad_pixels+font_size_pixels+h))
- trans = trans + tr
+ #trans = trans + tr
- return trans, "baseline", "center"
+ return tr, "baseline", "center"
elif self.label_direction == "top":
- #pad_points = font_size_points/8. + pad_points
- #tr.translate(0, +(pad_pixels+font_size_pixels/6.+h))
- #tr.translate(0, +(pad_pixels+font_size_pixels/10.+h))
tr.translate(0, +(pad_pixels+h))
- #tr = ScaledTranslation(0, (pad_points+h) / 72.,
- # dpi_scale_trans)
- trans = trans + tr
+ #trans = trans + tr
- return trans, "baseline", "center"
+ return tr, "baseline", "center"
else:
raise ValueError("")
- def get_label_transform(self, pad_points, fontprops, renderer,
- bboxes,
- trans=None):
+ def get_label_offset_transform(self,
+ axes,
+ pad_points, fontprops, renderer,
+ bboxes,
+ #trans=None
+ ):
- tr, va, ha = self._get_label_transform(pad_points, fontprops,
- renderer,
- bboxes, trans)
+ tr, va, ha = self._get_label_offset_transform(pad_points, fontprops,
+ renderer,
+ bboxes,
+ #trans
+ )
a = self._label_angles[self.label_direction]
return tr, va, ha, a
- def get_ticklabel_transform(self, pad_points, fontprops, renderer,
- trans=None):
- tr, va, ha = self._get_label_transform(pad_points, fontprops,
- renderer,
- None, trans)
+ def get_ticklabel_offset_transform(self, axes,
+ pad_points, fontprops,
+ renderer,
+ ):
+ tr, va, ha = self._get_label_offset_transform(pad_points, fontprops,
+ renderer,
+ None,
+ )
+
a = self._ticklabel_angles[self.label_direction]
return tr, va, ha, a
- def get_line_transform(self):
- return self.axes.transAxes
- def get_line(self):
- raise UnimplementedException("")
- def get_tick_transform(self):
- raise UnimplementedException("")
-
- def get_tick_iterators(self):
- raise UnimplementedException("")
-
-
class Fixed(_Base):
_default_passthru_pt = dict(left=(0, 0),
@@ -186,13 +288,13 @@
bottom=(0, 0),
top=(0, 1))
- def __init__(self, axes, loc, nth_coord=None,
+ def __init__(self,
+ loc, nth_coord=None,
passingthrough_point=None, label_direction=None):
"""
nth_coord = along which coordinate value varies
in 2d, nth_coord = 0 -> x axis, nth_coord = 1 -> y axis
"""
- self.axes = axes
if loc not in ["left", "right", "bottom", "top"]:
raise ValueError("%s" % loc)
@@ -203,9 +305,8 @@
nth_coord = 0
self.nth_coord = nth_coord
- self.axis = [self.axes.xaxis, self.axes.yaxis][self.nth_coord]
- super(AxisLineHelper.Fixed, self).__init__(loc)
+ super(AxisArtistHelper.Fixed, self).__init__(loc)
if passingthrough_point is None:
passingthrough_point = self._default_passthru_pt[loc]
@@ -220,113 +321,160 @@
fixed_coord = 1-nth_coord
_verts[:,fixed_coord] = self.passthru_pt[fixed_coord]
+ # axis line in transAxes
self._path = Path(_verts)
def get_nth_coord(self):
return self.nth_coord
- def get_line(self):
+ # LINE
+
+ def get_line(self, axes):
return self._path
- def get_label_pos(self):
+ def get_line_transform(self, axes):
+ return axes.transAxes
+
+ # LABLE
+
+ def get_label_pos(self, axes):
+ """
+ label reference position in transAxes.
+
+ get_label_transform() returns a transform of (transAxes+offset)
+ """
_verts = [0.5, 0.5]
nth_coord = self.nth_coord
fixed_coord = 1-nth_coord
_verts[fixed_coord] = self.passthru_pt[fixed_coord]
- return _verts, self.axes.transAxes
+ return _verts, axes.transAxes
- def get_tick_transform(self):
- trans_tick = [self.axes.get_xaxis_transform(),
- self.axes.get_yaxis_transform()][self.nth_coord]
- return trans_tick
+ def get_label_offset_transform(self, axes,
+ pad_points, fontprops, renderer,
+ bboxes,
+ ):
- def get_tick_iterators(self):
- """tick_loc, tick_angle, tick_label"""
+ tr, va, ha = self._get_label_offset_transform( \
+ pad_points, fontprops, renderer, bboxes,
+ #trans
+ )
- angle = 0 - 90 * self.nth_coord
- if self.passthru_pt[1 - self.nth_coord] > 0.5:
- angle = 180+angle
+ a = self._label_angles[self.label_direction]
+ #tr = axes.transAxes + tr
- major = self.axis.major
- majorLocs = major.locator()
- major.formatter.set_locs(majorLocs)
- majorLabels = [major.formatter(val, i) for i, val in enumerate(majorLocs)]
+ return tr, va, ha, a
- minor = self.axis.minor
- minorLocs = minor.locator()
- minor.formatter.set_locs(minorLocs)
- minorLabels = [minor.formatter(val, i) for i, val in enumerate(minorLocs)]
- trans_tick = self.get_tick_transform()
- tr2ax = trans_tick + self.axes.transAxes.inverted()
+ # TICK
- def _f(locs, labels):
- for x, l in zip(locs, labels):
+ def get_tick_transform(self, axes):
+ trans_tick = [axes.get_xaxis_transform(),
+ axes.get_yaxis_transform()][self.nth_coord]
- c = list(self.passthru_pt) # copy
- c[self.nth_coord] = x
+ return trans_tick
- c2 = tr2ax.transform_point(c)
- delta=0.001
- if 0. -delta<= c2[self.nth_coord] <= 1.+delta:
- yield c, angle, l
- return _f(majorLocs, majorLabels), _f(minorLocs, minorLabels)
-
class Floating(_Base):
- def __init__(self, axes, nth_coord,
+ def __init__(self, nth_coord,
passingthrough_point, label_direction, transform):
- self.axes = axes
self.nth_coord = nth_coord
- self.axis = [self.axes.xaxis, self.axes.yaxis][self.nth_coord]
self.passingthrough_point = passingthrough_point
self.transform = transform
- super(AxisLineHelper.Floating, self).__init__(label_direction)
+ super(AxisArtistHelper.Floating,
+ self).__init__(label_direction)
+
def get_nth_coord(self):
return self.nth_coord
- def get_line(self):
+ def get_line(self, axes):
_verts = np.array([[0., 0.],
[1., 1.]])
fixed_coord = 1-self.nth_coord
- trans_passingthrough_point = self.transform + self.axes.transAxes.inverted()
+ trans_passingthrough_point = self.transform + axes.transAxes.inverted()
p = trans_passingthrough_point.transform_point(self.passingthrough_point)
_verts[:,fixed_coord] = p[fixed_coord]
return Path(_verts)
+ def get_line_transform(self, axes):
+ return axes.transAxes
- def get_label_pos(self):
+ def get_label_pos(self, axes):
_verts = [0.5, 0.5]
fixed_coord = 1-self.nth_coord
- trans_passingthrough_point = self.transform + self.axes.transAxes.inverted()
+ trans_passingthrough_point = self.transform + axes.transAxes.inverted()
p = trans_passingthrough_point.transform_point(self.passingthrough_point)
_verts[fixed_coord] = p[fixed_coord]
if not (0. <= _verts[fixed_coord] <= 1.):
return None, None
else:
- return _verts, self.axes.transAxes
+ return _verts, axes.transAxes
+ def get_label_transform(self, axes,
+ pad_points, fontprops, renderer,
+ bboxes,
+ ):
+ tr, va, ha = self._get_label_offset_transform(pad_points, fontprops,
+ renderer,
+ bboxes,
+ #trans
+ )
- def get_tick_transform(self):
+ a = self._label_angles[self.label_direction]
+ tr = axes.transAxes + tr
+ #tr = axes.transAxes + tr
+
+ return tr, va, ha, a
+
+
+
+ def get_tick_transform(self, axes):
return self.transform
- def get_tick_iterators(self):
+
+
+
+
+class AxisArtistHelperRectlinear:
+
+ class Fixed(AxisArtistHelper.Fixed):
+
+ def __init__(self,
+ axes, loc, nth_coord=None,
+ passingthrough_point=None, label_direction=None):
+ """
+ nth_coord = along which coordinate value varies
+ in 2d, nth_coord = 0 -> x axis, nth_coord = 1 -> y axis
+ """
+
+ super(AxisArtistHelperRectlinear.Fixed, self).__init__( \
+ loc, nth_coord,
+ passingthrough_point, label_direction)
+
+ self.axis = [axes.xaxis, axes.yaxis][self.nth_coord]
+
+
+
+ # TICK
+
+ def get_tick_iterators(self, axes):
"""tick_loc, tick_angle, tick_label"""
angle = 0 - 90 * self.nth_coord
+ if self.passthru_pt[1 - self.nth_coord] > 0.5:
+ angle = 180+angle
major = self.axis.major
majorLocs = major.locator()
@@ -338,11 +486,56 @@
minor.formatter.set_locs(minorLocs)
minorLabels = [minor.formatter(val, i) for i, val in enumerate(minorLocs)]
- tr2ax = self.transform + self.axes.transAxes.inverted()
+ trans_tick = self.get_tick_transform(axes)
+ tr2ax = trans_tick + axes.transAxes.inverted()
+
def _f(locs, labels):
for x, l in zip(locs, labels):
+ c = list(self.passthru_pt) # copy
+ c[self.nth_coord] = x
+
+ # check if the tick point is inside axes
+ c2 = tr2ax.transform_point(c)
+ delta=0.001
+ if 0. -delta<= c2[self.nth_coord] <= 1.+delta:
+ yield c, angle, l
+
+ return _f(majorLocs, majorLabels), _f(minorLocs, minorLabels)
+
+
+
+ class Floating(AxisArtistHelper.Floating):
+ def __init__(self, axes, nth_coord,
+ passingthrough_point, label_direction, transform):
+
+ super(AxisArtistHelperRectlinear.Floating, self).__init__( \
+ nth_coord, passingthrough_point, label_direction, transform)
+
+ self.axis = [axes.xaxis, axes.yaxis][self.nth_coord]
+
+
+ def get_tick_iterators(self, axes):
+ """tick_loc, tick_angle, tick_label"""
+
+ angle = 0 - 90 * self.nth_coord
+
+ major = self.axis.major
+ majorLocs = major.locator()
+ major.formatter.set_locs(majorLocs)
+ majorLabels = [major.formatter(val, i) for i, val in enumerate(majorLocs)]
+
+ minor = self.axis.minor
+ minorLocs = minor.locator()
+ minor.formatter.set_locs(minorLocs)
+ minorLabels = [minor.formatter(val, i) for i, val in enumerate(minorLocs)]
+
+ tr2ax = self.transform + axes.transAxes.inverted()
+
+ def _f(locs, labels):
+ for x, l in zip(locs, labels):
+
c = list(self.passingthrough_point) # copy
c[self.nth_coord] = x
c1, c2 = tr2ax.transform_point(c)
@@ -352,34 +545,60 @@
return _f(majorLocs, majorLabels), _f(minorLocs, minorLabels)
-class GridHelperRectlinear(object):
+
+class GridHelperBase(object):
+
def __init__(self):
- self.axes = None
self._force_update = True
+ self._old_limits = None
+ super(GridHelperBase, self).__init__()
- def set_axes(self, axes):
- self.axes = axes
+ def update_lim(self, axes):
+ x1, x2 = axes.get_xlim()
+ y1, y2 = axes.get_ylim()
+
+ if self._force_update or self._old_limits != (x1, x2, y1, y2):
+ self._update(x1, x2, y1, y2)
+ self._force_update = False
+ self._old_limits = (x1, x2, y1, y2)
+
+
def _update(self, x1, x2, y1, y2):
- self._force_update = False
+ pass
+
def invalidate(self):
self._force_update = True
+
def get_gridlines(self):
return []
- def _get_axisline_helper(self, nth_coord, loc,
+
+
+class GridHelperRectlinear(GridHelperBase):
+
+
+ def __init__(self, axes):
+
+ super(GridHelperRectlinear, self).__init__()
+ self.axes = axes
+
+ #def set_axes(self, axes):
+ # self.axes = axes
+
+ def _get_axisline_helper_deprecated(self, nth_coord, loc,
passingthrough_point, transform=None):
if transform is None or transform is self.axes.transAxes:
- return AxisLineHelper.Fixed(self.axes, loc,
+ return AxisArtistHelper.Fixed(self.axes, loc,
nth_coord, passingthrough_point)
else:
label_direction = loc
- return AxisLineHelper.Floating(self.axes,
+ return AxisArtistHelper.Floating(self.axes,
nth_coord, passingthrough_point,
label_direction,
transform)
@@ -390,16 +609,23 @@
#transform=None,
tick_direction="in",
label_direction=None,
- offset=None):
+ offset=None,
+ axes=None,
+ ):
- _helper = AxisLineHelper.Fixed(self.axes, loc,
- nth_coord, passthrough_point)
+ if axes is None:
+ warnings.warn("'new_fixed_axis' explicitly requires the axes keyword.")
+ axes = self.axes
- axisline = AxisLine(self.axes, _helper,
- #tick_direction="in",
- offset=offset,
- )
+ _helper = AxisArtistHelperRectlinear.Fixed(axes, loc,
+ nth_coord,
+ passthrough_point)
+ axisline = AxisArtist(axes, _helper,
+ #tick_direction="in",
+ offset=offset,
+ )
+
return axisline
@@ -407,21 +633,27 @@
transform=None,
tick_direction="in",
label_direction=None,
- ):
+ axes=None,
+ ):
- _helper = AxisLineHelper.Floating(self.axes,
- nth_coord, passthrough_point,
- label_direction,
- transform)
+ if axes is None:
+ warnings.warn("'new_floating_axis' explicitly requires the axes keyword.")
+ axes = self.axes
- axisline = AxisLine(self.axes, _helper,
- #tick_direction="in",
- )
+ _helper = AxisArtistHelperRectlinear.Floating( \
+ axes,
+ nth_coord, passthrough_point,
+ label_direction,
+ transform)
+ axisline = AxisArtist(axes, _helper,
+ #tick_direction="in",
+ )
+
return axisline
- def new_axisline(self, loc,
+ def new_axisline_deprecated(self, loc,
nth_coord=None, passthrough_point=None,
transform=None,
tick_direction="in",
@@ -435,7 +667,7 @@
passthrough_point,
transform)
- axisline = AxisLine(self.axes, _helper,
+ axisline = AxisArtist(self.axes, _helper,
#tick_direction="in",
offset=offset,
)
@@ -444,18 +676,9 @@
-
-
-
-class XYEvent:
- def __init__(self, xy):
- self.x, self.y = xy
-
-
from matplotlib.lines import Line2D
class Ticks(Line2D):
-#LineCollection
def __init__(self, ticksize, **kwargs):
self.ticksize = ticksize
self.locs_angles = []
@@ -608,6 +831,9 @@
# return Bbox.from_bounds(0, 0, 0, 0)
+
+
+
class AxisLabel(mtext.Text):
def __init__(self, *kl, **kwargs):
self._axis = kwargs.pop("axis", None)
@@ -635,279 +861,40 @@
return self._text
-class AxisGridLineBase(martist.Artist):
- def __init__(self, *kl, **kw):
- super(AxisGridLineBase, self).__init__(*kl, **kw)
+class GridlinesCollection(LineCollection):
+ def __init__(self, *kl, **kwargs):
+ super(GridlinesCollection, self).__init__(*kl, **kwargs)
+ self.set_grid_helper(None)
+ def set_grid_helper(self, grid_helper):
+ self._grid_helper = grid_helper
-
-class GridLine(AxisGridLineBase):
- """ a line along which the n-th axes coord is constant."""
-
- LABELPAD = 5
- ZORDER=2.5
-
- def __init__(self, axes,
- helper,
- #offset_transform=None,
- offset=None,
- major_tick_size=None,
- major_tick_pad=None,
- minor_tick_size=None,
- minor_tick_pad=None,
- **kw):
-
- AxisGridLineBase.__init__(self, **kw)
-
- self.axes = axes
-
- self._helper = helper
-
- #if offset_transform is None:
- # self.offset_transform = IdentityTransform()
- #else:
- # self.offset_transform = offset_transform
-
- if offset is None:
- offset = (0, 0)
- self.dpi_transform = Affine2D()
- self.offset_transform = ScaledTranslation(offset[0], offset[1],
- self.dpi_transform)
-
- self.set_transform(axes.transAxes + \
- self.offset_transform)
-
- self._label_visible = True
- self._majortick_visible = True
- self._majorticklabel_visible = True
- self._minortick_visible = True
- self._minorticklabel_visible = True
-
-
- if self._helper.label_direction in ["left", "right"]:
- axis_name = "ytick"
- else:
- axis_name = "xtick"
-
-
- if major_tick_size is None:
- self.major_tick_size = rcParams['%s.major.size'%axis_name]
- if major_tick_pad is None:
- self.major_tick_pad = rcParams['%s.major.pad'%axis_name]
- if minor_tick_size is None:
- self.minor_tick_size = rcParams['%s.minor.size'%axis_name]
- if minor_tick_pad is None:
- self.minor_tick_pad = rcParams['%s.minor.pad'%axis_name]
-
- self._init_line()
- self._init_ticks()
- self._init_label()
-
- self.set_zorder(self.ZORDER)
-
- def _init_line(self):
- tran = self._helper.get_line_transform() + self.offset_transform
- self.line = BezierPath(self._helper.get_line(),
- color=rcParams['axes.edgecolor'],
- linewidth=rcParams['axes.linewidth'],
- transform=tran)
-
- def get_helper(self):
- return self._helper
-
- def _draw_line(self, renderer):
- self.line.set_path(self._helper.get_line())
- self.line.draw(renderer)
-
-
- def _init_ticks(self):
-
- transform=self._helper.get_tick_transform()+self.offset_transform
-
- self.major_ticks = Ticks(self.major_tick_size,
- transform=transform)
- self.minor_ticks = Ticks(self.minor_tick_size,
- transform=transform)
-
-
- size = rcParams['xtick.labelsize']
-
- fontprops = font_manager.FontProperties(size=size)
- tvhl = self._helper.get_ticklabel_transform(self.major_tick_pad,
- fontprops=fontprops,
- renderer=None,
- trans=transform)
- trans, vert, horiz, label_a = tvhl
-
- color = rcParams['xtick.color']
- self.major_ticklabels = TickLabels(size, color=color)
- self.minor_ticklabels = TickLabels(size, color=color)
-
- #self.major_ticklabels = TickLabels(size, axis=self.axis)
- #self.minor_ticklabels = TickLabels(size, axis=self.axis)
-
-
- self.major_ticklabels.set(figure = self.axes.figure,
- rotation = label_a,
- transform=trans,
- va=vert,
- ha=horiz,
- fontproperties=fontprops)
-
- self.minor_ticklabels.set(figure = self.axes.figure,
- rotation = label_a,
- transform=trans,
- va=vert,
- ha=horiz,
- fontproperties=fontprops)
-
-
- def _draw_ticks(self, renderer):
- #majortick_iter, minortick_iter):
- #major_locs, major_angles,
- #minor_locs, minor_angles):
-
- majortick_iter, minortick_iter = self._helper.get_tick_iterators()
-
- tick_loc_angles = []
- tick_loc_labels = []
- for tick_loc, tick_angle, tick_label in majortick_iter:
- tick_loc_angles.append((tick_loc, tick_angle))
- tick_loc_labels.append((tick_loc, tick_label))
-
-
- transform=self._helper.get_tick_transform()+self.offset_transform
- fontprops = font_manager.FontProperties(size=12)
- tvhl = self._helper.get_ticklabel_transform(self.major_tick_pad,
- fontprops=fontprops,
- renderer=renderer,
- trans=transform)
- trans, va, ha, a = tvhl
- self.major_ticklabels.set(transform=trans,
- va=va, ha=ha, rotation=a)
-
-
- self.major_ticks.update_locs_angles(tick_loc_angles, renderer)
- self.major_ticklabels.update_locs_labels(tick_loc_labels, renderer)
-
- self.major_ticks.draw(renderer)
- self.major_ticklabels.draw(renderer)
-
- tick_loc_angles = []
- tick_loc_labels = []
- for tick_loc, tick_angle, tick_label in minortick_iter:
- tick_loc_angles.append((tick_loc, tick_angle))
- tick_loc_labels.append((tick_loc, tick_label))
-
- self.minor_ticks.update_locs_angles(tick_loc_angles, renderer)
- self.minor_ticklabels.update_locs_labels(tick_loc_labels, renderer)
-
- self.minor_ticks.draw(renderer)
- self.minor_ticklabels.draw(renderer)
-
- return self.major_ticklabels.get_window_extents(renderer)
-
- def _init_label(self):
- # x in axes coords, y in display coords (to be updated at draw
- # time by _update_label_positions)
- fontprops = font_manager.FontProperties(size=rcParams['axes.labelsize'])
- textprops = dict(fontproperties = fontprops,
- color = rcParams['axes.labelcolor'],
- )
-
- self.label = AxisLabel(0, 0, "",
- fontproperties=fontprops,
- color = rcParams['axes.labelcolor'],
- )
- self.label.set_figure(self.axes.figure)
-
- #self._set_artist_props(label)
-
- def _draw_label(self, renderer, bboxes):
-
- if not self.label.get_visible():
- return
-
- fontprops = font_manager.FontProperties(size=rcParams['axes.labelsize'])
- pad_points = self.LABELPAD + self.major_tick_pad
- xy, tr = self._helper.get_label_pos()
- if xy is None: return
-
- x, y = xy
- tr2, va, ha, a = self._helper.get_label_transform(pad_points, fontprops,
- renderer,
- bboxes=bboxes,
- trans=tr+self.offset_transform)
-
- self.label.set(x=x, y=y,
- transform=tr2,
- va=va, ha=ha, rotation=a)
-
-# if self.label.get_text() == "__from_axes__":
-# label_text = self.axis.get_label().get_text()
-# self.label.set_text(label_text)
-# self.label.draw(renderer)
-# self.label.set_text("__from_axes__")
-# else:
-
- self.label.draw(renderer)
-
-
- def set_label(self, s):
- self.label.set_text(s)
-
-
def draw(self, renderer):
- 'Draw the axis lines, tick lines and labels'
+ if self._grid_helper is not None:
+ self._grid_helper.update_lim(self.axes)
+ #self.set_transform(self._grid_helper.get_gridlines_transform())
+ gl = self._grid_helper.get_gridlines()
+ if gl:
+ self.set_segments([np.transpose(l) for l in gl])
+ else:
+ self.set_segments([])
+ super(GridlinesCollection, self).draw(renderer)
- if not self.get_visible(): return
- renderer.open_group(__name__)
+class AxisGridLineBase(martist.Artist):
+ def __init__(self, *kl, **kw):
+ super(AxisGridLineBase, self).__init__(*kl, **kw)
- dpi_cor = renderer.points_to_pixels(1.)
- self.dpi_transform.clear().scale(dpi_cor, dpi_cor)
+class AxisArtist(AxisGridLineBase):
+ """
+ an artist which draws axis (a line along which the n-th axes coord
+ is constant) line, ticks, ticklabels, and axis label.
- self._draw_line(renderer)
- bboxes = self._draw_ticks(renderer)
+ It requires an AxisArtistHelper instance.
+ """
- #self._draw_offsetText(renderer)
- self._draw_label(renderer, bboxes)
-
- renderer.close_group(__name__)
-
- def get_ticklabel_extents(self, renderer):
- pass
-
- def toggle(self, all=None, ticks=None, ticklabels=None, label=None):
- if all:
- _ticks, _ticklabels, _label = True, True, True
- elif all is not None:
- _ticks, _ticklabels, _label = False, False, False
- else:
- _ticks, _ticklabels, _label = None, None, None
-
- if ticks is not None:
- _ticks = ticks
- if ticklabels is not None:
- _ticklabels = ticklabels
- if label is not None:
- _label = label
-
- if _ticks is not None:
- self.major_ticks.set_visible(_ticks)
- self.minor_ticks.set_visible(_ticks)
- if _ticklabels is not None:
- self.major_ticklabels.set_visible(_ticklabels)
- self.minor_ticklabels.set_visible(_ticklabels)
- if _label is not None:
- self.label.set_visible(_label)
-
-
-class AxisLine(AxisGridLineBase):
- """ a line along which the n-th axes coord is constant."""
-
LABELPAD = 5
ZORDER=2.5
@@ -920,26 +907,23 @@
minor_tick_size=None,
minor_tick_pad=None,
**kw):
-
+ """
+ axes is also used to follow the axis attribute (tick color, etc).
+ """
AxisGridLineBase.__init__(self, **kw)
self.axes = axes
- self._helper = helper
+ self._axis_artist_helper = helper
- #if offset_transform is None:
- # self.offset_transform = IdentityTransform()
- #else:
- # self.offset_transform = offset_transform
-
if offset is None:
offset = (0, 0)
self.dpi_transform = Affine2D()
self.offset_transform = ScaledTranslation(offset[0], offset[1],
self.dpi_transform)
- self.set_transform(axes.transAxes + \
- self.offset_transform)
+ #self.set_transform(axes.transAxes + \
+ # self.offset_transform)
self._label_visible = True
self._majortick_visible = True
@@ -948,7 +932,7 @@
self._minorticklabel_visible = True
- if self._helper.label_direction in ["left", "right"]:
+ if self._axis_artist_helper.label_direction in ["left", "right"]:
axis_name = "ytick"
self.axis = axes.yaxis
else:
@@ -967,29 +951,35 @@
self._init_line()
self._init_ticks()
- self._init_offsetText(self._helper.label_direction)
+ self._init_offsetText(self._axis_artist_helper.label_direction)
self._init_label()
self.set_zorder(self.ZORDER)
+ def get_transform(self):
+ return self.axes.transAxes + self.offset_transform
+
+ def get_helper(self):
+ return self._axis_artist_helper
+
+
def _init_line(self):
- tran = self._helper.get_line_transform() + self.offset_transform
- self.line = BezierPath(self._helper.get_line(),
+ tran = self._axis_artist_helper.get_line_transform(self.axes) \
+ + self.offset_transform
+ self.line = BezierPath(self._axis_artist_helper.get_line(self.axes),
color=rcParams['axes.edgecolor'],
linewidth=rcParams['axes.linewidth'],
transform=tran)
- def get_helper(self):
- return self._helper
-
def _draw_line(self, renderer):
- self.line.set_path(self._helper.get_line())
+ self.line.set_path(self._axis_artist_helper.get_line(self.axes))
self.line.draw(renderer)
def _init_ticks(self):
- transform=self._helper.get_tick_transform()+self.offset_transform
+ transform=self._axis_artist_helper.get_tick_transform(self.axes) \
+ + self.offset_transform
self.major_ticks = Ticks(self.major_tick_size,
axis=self.axis,
@@ -1002,16 +992,17 @@
size = rcParams['xtick.labelsize']
fontprops = font_manager.FontProperties(size=size)
- tvhl = self._helper.get_ticklabel_transform(self.major_tick_pad,
- fontprops=fontprops,
- renderer=None,
- trans=transform)
+ #tvhl = self._axis_artist_helper.get_ticklabel_transform(
+ tvhl = self._axis_artist_helper.get_ticklabel_offset_transform( \
+ self.axes,
+ self.major_tick_pad,
+ fontprops=fontprops,
+ renderer=None,
+ )
+ #trans=transform)
trans, vert, horiz, label_a = tvhl
+ trans = transform + trans
- #color = rcParams['xtick.color']
- #self.major_ticklabels = TickLabels(size, color=color)
- #self.minor_ticklabels = TickLabels(size, color=color)
-
self.major_ticklabels = TickLabels(size, axis=self.axis)
self.minor_ticklabels = TickLabels(size, axis=self.axis)
@@ -1040,7 +1031,7 @@
x,y,va,ha = self._offsetText_pos[direction]
- #d = self._helper.label_direction
+ #d = self._axis_artist_helper.label_direction
#fp = font_manager.FontProperties(size=rcParams['xtick.labelsize'])
#fp = font_manager.FontProperties(size=self.major_ticklabels.get_size())
self.offsetText = mtext.Annotation("",
@@ -1056,7 +1047,7 @@
def _update_offsetText(self):
- self.offsetText.set_text( self._helper.axis.major.formatter.get_offset() )
+ self.offsetText.set_text( self.axis.major.formatter.get_offset() )
self.offsetText.set_size(self.major_ticklabels.get_size())
offset = self.major_tick_pad + self.major_ticklabels.get_size() + 2.
self.offsetText.xytext= (0, offset)
@@ -1072,7 +1063,8 @@
#major_locs, major_angles,
#minor_locs, minor_angles):
- majortick_iter, minortick_iter = self._helper.get_tick_iterators()
+ majortick_iter, minortick_iter = \
+ self._axis_artist_helper.get_tick_iterators(self.axes)
tick_loc_angles = []
tick_loc_labels = []
@@ -1081,13 +1073,19 @@
tick_loc_labels.append((tick_loc, tick_label))
- transform=self._helper.get_tick_transform()+self.offset_transform
+ transform=self._axis_artist_helper.get_tick_transform(self.axes) \
+ + self.offset_transform
fontprops = font_manager.FontProperties(size=12)
- tvhl = self._helper.get_ticklabel_transform(self.major_tick_pad,
- fontprops=fontprops,
- renderer=renderer,
- trans=transform)
+ tvhl = self._axis_artist_helper.get_ticklabel_offset_transform( \
+ self.axes,
+ self.major_tick_pad,
+ fontprops=fontprops,
+ renderer=renderer,
+ )
+ #trans=transform)
trans, va, ha, a = tvhl
+ trans = transform + trans
+
self.major_ticklabels.set(transform=trans,
va=va, ha=ha, rotation=a)
@@ -1140,14 +1138,18 @@
fontprops = font_manager.FontProperties(size=rcParams['axes.labelsize'])
pad_points = self.LABELPAD + self.major_tick_pad
- xy, tr = self._helper.get_label_pos()
+ xy, tr = self._axis_artist_helper.get_label_pos(self.axes)
if xy is None: return
x, y = xy
- tr2, va, ha, a = self._helper.get_label_transform(pad_points, fontprops,
- renderer,
- bboxes=bboxes,
- trans=tr+self.offset_transform)
+ tr2, va, ha, a = self._axis_artist_helper.get_label_offset_transform(\
+ self.axes,
+ pad_points, fontprops,
+ renderer,
+ bboxes=bboxes,
+ )
+ #trans=tr+self.offset_transform)
+ tr2 = (tr+self.offset_transform) + tr2
self.label.set(x=x, y=y,
transform=tr2,
@@ -1174,6 +1...
[truncated message content] |
|
From: <cm...@us...> - 2009-06-02 02:31:03
|
Revision: 7174
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7174&view=rev
Author: cmoad
Date: 2009-06-02 02:30:57 +0000 (Tue, 02 Jun 2009)
Log Message:
-----------
comment fixes
Modified Paths:
--------------
trunk/matplotlib/release/win32/Makefile
Modified: trunk/matplotlib/release/win32/Makefile
===================================================================
--- trunk/matplotlib/release/win32/Makefile 2009-06-02 00:31:45 UTC (rev 7173)
+++ trunk/matplotlib/release/win32/Makefile 2009-06-02 02:30:57 UTC (rev 7174)
@@ -1,11 +1,11 @@
PYTHON = C:/Python26/python.exe
-SRCDIR = ${PWD}# autoconf needs this path
-WINSRCDIR = `${PWD}/data/mingw_path.sh ${PWD}`# distutils needs windows paths
+SRCDIR = ${PWD}
+WINSRCDIR = `${PWD}/data/mingw_path.sh ${PWD}`
ZLIBVERSION = 1.2.3
-PNGVERSION = 1.2.33
-FREETYPEVERSION = 2.3.7
-#TCLTKVERSION = 8.4.19# Before Python 2.6
-TCLTKVERSION = 8.5.7# Python 2.6
+PNGVERSION = 1.2.23
+FREETYPEVERSION = 2.3.9
+#TCLTKVERSION = 8.4.19
+TCLTKVERSION = 8.5.7
MPLVERSION = 0.98.6svn
## You shouldn't need to configure past this point
@@ -24,7 +24,7 @@
LDFLAGS += -L${SRCDIR}/libpng-${PNGVERSION}
LDFLAGS += -L${SRCDIR}/freetype-${FREETYPEVERSION}
-PY_INCLUDE = "${WINSRCDIR}/zlib-${ZLIBVERSION};${WINSRCDIR}/libpng-${PNGVERSION};${WINSRCDIR}/freetype-${FREETYPEVERSION}/include;${WINSRCDIR}/tcl${TCLTKVERSION}/generic;${WINSRCDIR}/tcl${TCLTKVERSION}/win;${WINSRCDIR}/tk${TCLTKVERSION}/generic;${WINSRCDIR}/tk${TCLTKVERSION}/win;${WINSRCDIR}/tk${TCLTKVERSION}/xlib"
+PY_INCLUDE = "${WINSRCDIR}\\zlib-${ZLIBVERSION};${WINSRCDIR}/libpng-${PNGVERSION};${WINSRCDIR}/freetype-${FREETYPEVERSION}/include;${WINSRCDIR}/tcl${TCLTKVERSION}/generic;${WINSRCDIR}/tcl${TCLTKVERSION}/win;${WINSRCDIR}/tk${TCLTKVERSION}/generic;${WINSRCDIR}/tk${TCLTKVERSION}/win;${WINSRCDIR}/tk${TCLTKVERSION}/xlib"
PY_LINKER = "${WINSRCDIR}/zlib-${ZLIBVERSION};${WINSRCDIR}/libpng-${PNGVERSION};${WINSRCDIR}/freetype-${FREETYPEVERSION}"
@@ -38,8 +38,8 @@
fetch_deps:
wget http://www.zlib.net/zlib-${ZLIBVERSION}.tar.gz
- wget http://internap.dl.sourceforge.net/sourceforge/libpng/libpng-${PNGVERSION}.tar.bz2
- wget http://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPEVERSION}.tar.bz2
+ wget http://prdownloads.sourceforge.net/libpng/libpng-${PNGVERSION}.tar.bz2
+ wget http://prdownloads.sourceforge.net/freetype/freetype-2.3.9.tar.bz2
wget http://prdownloads.sourceforge.net/tcl/tcl${TCLTKVERSION}-src.tar.gz
wget http://prdownloads.sourceforge.net/tcl/tk${TCLTKVERSION}-src.tar.gz
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-06-02 01:14:37
|
Revision: 7173
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7173&view=rev
Author: leejjoon
Date: 2009-06-02 00:31:45 +0000 (Tue, 02 Jun 2009)
Log Message:
-----------
axes_grid: fix broken spine support
Modified Paths:
--------------
trunk/matplotlib/examples/axes_grid/simple_axisline.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/ChangeLog
trunk/matplotlib/lib/mpl_toolkits/axes_grid/axes_rgb.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py
Modified: trunk/matplotlib/examples/axes_grid/simple_axisline.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/simple_axisline.py 2009-06-01 22:39:49 UTC (rev 7172)
+++ trunk/matplotlib/examples/axes_grid/simple_axisline.py 2009-06-02 00:31:45 UTC (rev 7173)
@@ -26,7 +26,8 @@
# make new (right-side) yaxis, but wth some offset
offset = (20, 0)
- new_axisline = ax.get_grid_helper().new_axisline
+ new_axisline = ax.get_grid_helper().new_fixed_axis
+
ax.axis["right2"] = new_axisline(loc="right",
offset=offset)
ax.axis["right2"].label.set_text("Label Y2")
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/ChangeLog
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/ChangeLog 2009-06-01 22:39:49 UTC (rev 7172)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/ChangeLog 2009-06-02 00:31:45 UTC (rev 7173)
@@ -1,3 +1,7 @@
+2009-06-01 Jae-Joon Lee <lee...@gm...>
+
+ * axislines.py (Axes.toggle_axisline): fix broken spine support.
+
2009-05-04 Jae-Joon Lee <lee...@gm...>
* inset_locator.py (inset_axes, zoomed_inset_axes): axes_class support
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/axes_rgb.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/axes_rgb.py 2009-06-01 22:39:49 UTC (rev 7172)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/axes_rgb.py 2009-06-02 00:31:45 UTC (rev 7173)
@@ -10,8 +10,8 @@
pad_size = Size.Fraction(pad, Size.AxesY(ax))
- xsize = Size.Fraction(Size.AxesX(ax), (1.-2.*pad)/3.)
- ysize = Size.Fraction(Size.AxesY(ax), (1.-2.*pad)/3.)
+ xsize = Size.Fraction((1.-2.*pad)/3., Size.AxesX(ax))
+ ysize = Size.Fraction((1.-2.*pad)/3., Size.AxesY(ax))
divider.set_horizontal([Size.AxesX(ax), pad_size, xsize])
divider.set_vertical([ysize, pad_size, ysize, pad_size, ysize])
@@ -51,6 +51,22 @@
#import matplotlib.axes as maxes
import axislines
+def imshow_rgb(ax, r, g, b, **kwargs):
+ ny, nx = r.shape
+ R = np.zeros([ny, nx, 3], dtype="d")
+ R[:,:,0] = r
+ G = np.zeros_like(R)
+ G[:,:,1] = g
+ B = np.zeros_like(R)
+ B[:,:,2] = b
+
+ RGB = R + G + B
+
+ im_rgb = ax.imshow(RGB, **kwargs)
+
+ return im_rgb
+
+
class RGBAxes(object):
def __init__(self, *kl, **kwargs):
pad = kwargs.pop("pad", 0.0)
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py 2009-06-01 22:39:49 UTC (rev 7172)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py 2009-06-02 00:31:45 UTC (rev 7173)
@@ -1249,16 +1249,14 @@
b = not self._axisline_on
if b:
self._axisline_on = True
- #self.frame.set_visible(False)
for s in self.spines.values():
- s.artist.set_visible(False)
+ s.set_visible(False)
self.xaxis.set_visible(False)
self.yaxis.set_visible(False)
else:
self._axisline_on = False
- #self.frame.set_visible(True)
for s in self.spines.values():
- s.artist.set_visible(True)
+ s.set_visible(True)
self.xaxis.set_visible(True)
self.yaxis.set_visible(True)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2009-06-01 22:39:54
|
Revision: 7172
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7172&view=rev
Author: astraw
Date: 2009-06-01 22:39:49 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
Add set_color() convenience method to Spine class
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/spine_placement_demo.py
trunk/matplotlib/lib/matplotlib/spines.py
Modified: trunk/matplotlib/examples/pylab_examples/spine_placement_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/spine_placement_demo.py 2009-06-01 22:20:26 UTC (rev 7171)
+++ trunk/matplotlib/examples/pylab_examples/spine_placement_demo.py 2009-06-01 22:39:49 UTC (rev 7172)
@@ -12,7 +12,7 @@
if loc in ['left','bottom']:
spine.set_position(('outward',10)) # outward by 10 points
elif loc in ['right','top']:
- spine.set_edgecolor('none') # don't draw spine
+ spine.set_color('none') # don't draw spine
else:
raise ValueError('unknown spine location: %s'%loc)
@@ -34,9 +34,9 @@
ax.set_title('centered spines')
ax.plot(x,y)
ax.spines['left'].set_position('center')
-ax.spines['right'].set_edgecolor('none')
+ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('center')
-ax.spines['top'].set_edgecolor('none')
+ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
@@ -44,9 +44,9 @@
ax.set_title('zeroed spines')
ax.plot(x,y)
ax.spines['left'].set_position('zero')
-ax.spines['right'].set_edgecolor('none')
+ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
-ax.spines['top'].set_edgecolor('none')
+ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
@@ -54,9 +54,9 @@
ax.set_title('spines at axes (0.6, 0.1)')
ax.plot(x,y)
ax.spines['left'].set_position(('axes',0.6))
-ax.spines['right'].set_edgecolor('none')
+ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position(('axes',0.1))
-ax.spines['top'].set_edgecolor('none')
+ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
@@ -64,9 +64,9 @@
ax.set_title('spines at data (1,2)')
ax.plot(x,y)
ax.spines['left'].set_position(('data',1))
-ax.spines['right'].set_edgecolor('none')
+ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position(('data',2))
-ax.spines['top'].set_edgecolor('none')
+ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
@@ -77,7 +77,7 @@
if loc in spines:
spine.set_position(('outward',10)) # outward by 10 points
else:
- spine.set_edgecolor('none') # don't draw spine
+ spine.set_color('none') # don't draw spine
# turn off ticks where there is no spine
if 'left' in spines:
Modified: trunk/matplotlib/lib/matplotlib/spines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/spines.py 2009-06-01 22:20:26 UTC (rev 7171)
+++ trunk/matplotlib/lib/matplotlib/spines.py 2009-06-01 22:39:49 UTC (rev 7172)
@@ -303,3 +303,18 @@
result = cls(axes,spine_type,path,**kwargs)
result.set_patch_circle(center,radius)
return result
+
+ def set_color(self, c):
+ """
+ Set the edgecolor.
+
+ ACCEPTS: matplotlib color arg or sequence of rgba tuples
+
+ .. seealso::
+
+ :meth:`set_facecolor`, :meth:`set_edgecolor`
+ For setting the edge or face color individually.
+ """
+ # The facecolor of a spine is always 'none' by default -- let
+ # the user change it manually if desired.
+ self.set_edgecolor(c)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-06-01 22:20:28
|
Revision: 7171
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7171&view=rev
Author: efiring
Date: 2009-06-01 22:20:26 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
Add set_color method to Patch, to match Collections
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-06-01 21:41:46 UTC (rev 7170)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-06-01 22:20:26 UTC (rev 7171)
@@ -199,6 +199,21 @@
"""alias for set_facecolor"""
return self.set_facecolor(color)
+ def set_color(self, c):
+ """
+ Set both the edgecolor and the facecolor.
+
+ ACCEPTS: matplotlib color arg or sequence of rgba tuples
+
+ .. seealso::
+
+ :meth:`set_facecolor`, :meth:`set_edgecolor`
+ For setting the edge or face color individually.
+ """
+ self.set_facecolor(c)
+ self.set_edgecolor(c)
+
+
def set_linewidth(self, w):
"""
Set the patch linewidth in points
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2009-06-01 21:42:01
|
Revision: 7169
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7169&view=rev
Author: astraw
Date: 2009-06-01 21:41:31 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
use cbook.is_string_like() instead of isinstance() for spines
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/spines.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-06-01 21:41:21 UTC (rev 7168)
+++ trunk/matplotlib/CHANGELOG 2009-06-01 21:41:31 UTC (rev 7169)
@@ -1,3 +1,5 @@
+2009-06-01 use cbook.is_string_like() instead of isinstance() for spines - ADS
+
2009-06-01 cla() support for spines - ADS
2009-06-01 Removed support for gtk < 2.4. - EF
Modified: trunk/matplotlib/lib/matplotlib/spines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/spines.py 2009-06-01 21:41:21 UTC (rev 7168)
+++ trunk/matplotlib/lib/matplotlib/spines.py 2009-06-01 21:41:31 UTC (rev 7169)
@@ -8,6 +8,7 @@
import matplotlib.transforms as mtransforms
import matplotlib.lines as mlines
import matplotlib.patches as mpatches
+import matplotlib.cbook as cbook
import warnings
class Spine(martist.Artist):
@@ -87,7 +88,7 @@
"""calculate the offset transform performed by the spine"""
self._ensure_position_is_set()
position = self._position
- if isinstance(position,basestring):
+ if cbook.is_string_like(position):
if position=='center':
position = ('axes',0.5)
elif position=='zero':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2009-06-01 21:41:48
|
Revision: 7170
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7170&view=rev
Author: astraw
Date: 2009-06-01 21:41:46 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
Spine is now derived from Patch
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/examples/api/custom_projection_example.py
trunk/matplotlib/examples/pylab_examples/spine_placement_demo.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/projections/geo.py
trunk/matplotlib/lib/matplotlib/projections/polar.py
trunk/matplotlib/lib/matplotlib/spines.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-06-01 21:41:31 UTC (rev 7169)
+++ trunk/matplotlib/CHANGELOG 2009-06-01 21:41:46 UTC (rev 7170)
@@ -1,3 +1,5 @@
+2009-06-01 Spine is now derived from Patch - ADS
+
2009-06-01 use cbook.is_string_like() instead of isinstance() for spines - ADS
2009-06-01 cla() support for spines - ADS
Modified: trunk/matplotlib/examples/api/custom_projection_example.py
===================================================================
--- trunk/matplotlib/examples/api/custom_projection_example.py 2009-06-01 21:41:31 UTC (rev 7169)
+++ trunk/matplotlib/examples/api/custom_projection_example.py 2009-06-01 21:41:46 UTC (rev 7170)
@@ -237,7 +237,8 @@
return Circle((0.5, 0.5), 0.5)
def _gen_axes_spines(self):
- return {'hammer':mspines.Spine(self,'hammer',Circle((0.5, 0.5), 0.5))}
+ return {'hammer':mspines.Spine.circular_spine(self,
+ (0.5, 0.5), 0.5)}
# Prevent the user from applying scales to one or both of the
# axes. In this particular case, scaling the axes wouldn't make
Modified: trunk/matplotlib/examples/pylab_examples/spine_placement_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/spine_placement_demo.py 2009-06-01 21:41:31 UTC (rev 7169)
+++ trunk/matplotlib/examples/pylab_examples/spine_placement_demo.py 2009-06-01 21:41:46 UTC (rev 7170)
@@ -12,7 +12,7 @@
if loc in ['left','bottom']:
spine.set_position(('outward',10)) # outward by 10 points
elif loc in ['right','top']:
- spine.set_color('none') # don't draw spine
+ spine.set_edgecolor('none') # don't draw spine
else:
raise ValueError('unknown spine location: %s'%loc)
@@ -34,9 +34,9 @@
ax.set_title('centered spines')
ax.plot(x,y)
ax.spines['left'].set_position('center')
-ax.spines['right'].set_color('none')
+ax.spines['right'].set_edgecolor('none')
ax.spines['bottom'].set_position('center')
-ax.spines['top'].set_color('none')
+ax.spines['top'].set_edgecolor('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
@@ -44,9 +44,9 @@
ax.set_title('zeroed spines')
ax.plot(x,y)
ax.spines['left'].set_position('zero')
-ax.spines['right'].set_color('none')
+ax.spines['right'].set_edgecolor('none')
ax.spines['bottom'].set_position('zero')
-ax.spines['top'].set_color('none')
+ax.spines['top'].set_edgecolor('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
@@ -54,9 +54,9 @@
ax.set_title('spines at axes (0.6, 0.1)')
ax.plot(x,y)
ax.spines['left'].set_position(('axes',0.6))
-ax.spines['right'].set_color('none')
+ax.spines['right'].set_edgecolor('none')
ax.spines['bottom'].set_position(('axes',0.1))
-ax.spines['top'].set_color('none')
+ax.spines['top'].set_edgecolor('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
@@ -64,9 +64,9 @@
ax.set_title('spines at data (1,2)')
ax.plot(x,y)
ax.spines['left'].set_position(('data',1))
-ax.spines['right'].set_color('none')
+ax.spines['right'].set_edgecolor('none')
ax.spines['bottom'].set_position(('data',2))
-ax.spines['top'].set_color('none')
+ax.spines['top'].set_edgecolor('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
@@ -77,7 +77,7 @@
if loc in spines:
spine.set_position(('outward',10)) # outward by 10 points
else:
- spine.set_color('none') # don't draw spine
+ spine.set_edgecolor('none') # don't draw spine
# turn off ticks where there is no spine
if 'left' in spines:
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-06-01 21:41:31 UTC (rev 7169)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-06-01 21:41:46 UTC (rev 7170)
@@ -891,14 +891,10 @@
Intended to be overridden by new projection types.
"""
return {
- 'left':mspines.Spine(self,'left',
- mlines.Line2D((0.0, 0.0), (0.0, 1.0))),
- 'right':mspines.Spine(self,'right',
- mlines.Line2D((1.0, 1.0), (0.0, 1.0))),
- 'bottom':mspines.Spine(self,'bottom',
- mlines.Line2D((0.0, 1.0), (0.0, 0.0))),
- 'top':mspines.Spine(self,'top',
- mlines.Line2D((0.0, 1.0), (1.0, 1.0))),
+ 'left':mspines.Spine.linear_spine(self,'left'),
+ 'right':mspines.Spine.linear_spine(self,'right'),
+ 'bottom':mspines.Spine.linear_spine(self,'bottom'),
+ 'top':mspines.Spine.linear_spine(self,'top'),
}
def cla(self):
Modified: trunk/matplotlib/lib/matplotlib/projections/geo.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/projections/geo.py 2009-06-01 21:41:31 UTC (rev 7169)
+++ trunk/matplotlib/lib/matplotlib/projections/geo.py 2009-06-01 21:41:46 UTC (rev 7170)
@@ -145,7 +145,8 @@
return Circle((0.5, 0.5), 0.5)
def _gen_axes_spines(self):
- return {'geo':mspines.Spine(self,'geo',Circle((0.5, 0.5), 0.5))}
+ return {'geo':mspines.Spine.circular_spine(self,
+ (0.5, 0.5), 0.5)}
def set_yscale(self, *args, **kwargs):
if args[0] != 'linear':
Modified: trunk/matplotlib/lib/matplotlib/projections/polar.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/projections/polar.py 2009-06-01 21:41:31 UTC (rev 7169)
+++ trunk/matplotlib/lib/matplotlib/projections/polar.py 2009-06-01 21:41:46 UTC (rev 7170)
@@ -294,7 +294,8 @@
return Circle((0.5, 0.5), 0.5)
def _gen_axes_spines(self):
- return {'polar':mspines.Spine(self,'polar',Circle((0.5, 0.5), 0.5))}
+ return {'polar':mspines.Spine.circular_spine(self,
+ (0.5, 0.5), 0.5)}
def set_rmax(self, rmax):
self.viewLim.y0 = 0
Modified: trunk/matplotlib/lib/matplotlib/spines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/spines.py 2009-06-01 21:41:31 UTC (rev 7169)
+++ trunk/matplotlib/lib/matplotlib/spines.py 2009-06-01 21:41:46 UTC (rev 7170)
@@ -8,10 +8,11 @@
import matplotlib.transforms as mtransforms
import matplotlib.lines as mlines
import matplotlib.patches as mpatches
+import matplotlib.path as mpath
import matplotlib.cbook as cbook
import warnings
-class Spine(martist.Artist):
+class Spine(mpatches.Patch):
"""an axis spine -- the line noting the data area boundaries
Spines are the lines connecting the axis tick marks and noting the
@@ -20,39 +21,98 @@
for more information.
The default position is ``('outward',0)``.
+
+ Spines are subclasses of class:`~matplotlib.patches.Patch`, and
+ inherit much of their behavior.
+
+ Spines draw a line or a circle, depending if
+ function:`~matplotlib.spines.Spine.set_patch_line` or
+ function:`~matplotlib.spines.Spine.set_patch_circle` has been
+ called. Line-like is the default.
+
"""
def __str__(self):
return "Spine"
- def __init__(self,axes,spine_type,artist):
+ def __init__(self,axes,spine_type,path,**kwargs):
"""
- *axes* : the Axes instance containing the spine
- *spine_type* : a string specifying the spine type
- - *artist* : the artist instance used to draw the spine
+ - *path* : the path instance used to draw the spine
+
+ Valid kwargs are:
+ %(Patch)s
"""
- martist.Artist.__init__(self)
+ super(Spine,self).__init__(**kwargs)
self.axes = axes
self.set_figure(self.axes.figure)
self.spine_type = spine_type
- self.artist = artist
- self.color = rcParams['axes.edgecolor']
+ self.set_facecolor('none')
+ self.set_edgecolor( rcParams['axes.edgecolor'] )
+ self.set_linewidth(rcParams['axes.linewidth'])
self.axis = None
- if isinstance(self.artist,mlines.Line2D):
- self.artist.set_color(self.color)
- self.artist.set_linewidth(rcParams['axes.linewidth'])
- elif isinstance(self.artist,mpatches.Patch):
- self.artist.set_facecolor('none')
- self.artist.set_edgecolor(self.color)
- self.artist.set_linewidth(rcParams['axes.linewidth'])
- self.artist.set_zorder(2.5)
- self.artist.set_transform(self.axes.transAxes) # default transform
+ self.set_zorder(2.5)
+ self.set_transform(self.axes.transAxes) # default transform
# Defer initial position determination. (Not much support for
# non-rectangular axes is currently implemented, and this lets
# them pass through the spines machinery without errors.)
self._position = None
+ assert isinstance(path,matplotlib.path.Path)
+ self._path = path
+ # To support drawing both linear and circular spines, this
+ # class implements Patch behavior two ways. If
+ # self._patch_type == 'line', behave like a mpatches.PathPatch
+ # instance. If self._patch_type == 'circle', behave like a
+ # mpatches.Ellipse instance.
+ self._patch_type = 'line'
+
+ # Behavior copied from mpatches.Ellipse:
+ # Note: This cannot be calculated until this is added to an Axes
+ self._patch_transform = mtransforms.IdentityTransform()
+ __init__.__doc__ = cbook.dedent(__init__.__doc__) % martist.kwdocd
+
+ def set_patch_circle(self,center,radius):
+ """set the spine to be circular"""
+ self._patch_type = 'circle'
+ self._center = center
+ self._width = radius*2
+ self._height = radius*2
+ self._angle = 0
+
+ def set_patch_line(self):
+ """set the spine to be linear"""
+ self._patch_type = 'line'
+
+ # Behavior copied from mpatches.Ellipse:
+ def _recompute_transform(self):
+ """NOTE: This cannot be called until after this has been added
+ to an Axes, otherwise unit conversion will fail. This
+ maxes it very important to call the accessor method and
+ not directly access the transformation member variable.
+ """
+ assert self._patch_type == 'circle'
+ center = (self.convert_xunits(self._center[0]),
+ self.convert_yunits(self._center[1]))
+ width = self.convert_xunits(self._width)
+ height = self.convert_yunits(self._height)
+ self._patch_transform = mtransforms.Affine2D() \
+ .scale(width * 0.5, height * 0.5) \
+ .rotate_deg(self._angle) \
+ .translate(*center)
+
+ def get_patch_transform(self):
+ if self._patch_type == 'circle':
+ self._recompute_transform()
+ return self._patch_transform
+ else:
+ return super(Spine,self).get_patch_transform()
+
+ def get_path(self):
+ return self._path
+
def _ensure_position_is_set(self):
if self._position is None:
# default position
@@ -76,14 +136,6 @@
if self.axis is not None:
self.axis.cla()
- @allow_rasterization
- def draw(self,renderer):
- "draw everything that belongs to the spine"
- if self.color=='none':
- # don't draw invisible spines
- return
- self.artist.draw(renderer)
-
def _calc_offset_transform(self):
"""calculate the offset transform performed by the spine"""
self._ensure_position_is_set()
@@ -176,7 +228,7 @@
elif self.spine_type in ['bottom','top']:
t2 = mtransforms.blended_transform_factory(self.axes.transAxes,
t)
- self.artist.set_transform(t2)
+ self.set_transform(t2)
if self.axis is not None:
self.axis.cla()
@@ -223,17 +275,31 @@
else:
raise ValueError("unknown spine_transform type: %s"%what)
- def set_color(self,value):
- """set the color of the spine artist
+ @classmethod
+ def linear_spine(cls, axes, spine_type, **kwargs):
+ """
+ (staticmethod) Returns a linear :class:`Spine`.
+ """
+ if spine_type=='left':
+ path = mpath.Path([(0.0, 0.0), (0.0, 1.0)])
+ elif spine_type=='right':
+ path = mpath.Path([(1.0, 0.0), (1.0, 1.0)])
+ elif spine_type=='bottom':
+ path = mpath.Path([(0.0, 0.0), (1.0, 0.0)])
+ elif spine_type=='top':
+ path = mpath.Path([(0.0, 1.0), (1.0, 1.0)])
+ else:
+ raise ValueError('unable to make path for spine "%s"'%spine_type)
+ result = cls(axes,spine_type,path,**kwargs)
+ return result
- Note: a value of 'none' will cause the artist not to be drawn.
+ @classmethod
+ def circular_spine(cls,axes,center,radius,**kwargs):
"""
- self.color = value
- if isinstance(self.artist,mlines.Line2D):
- self.artist.set_color(self.color)
- elif isinstance(self.artist,mpatches.Patch):
- self.artist.set_edgecolor(self.color)
-
- def get_color(self):
- """get the color of the spine artist"""
- return self.color
+ (staticmethod) Returns a circular :class:`Spine`.
+ """
+ path = mpath.Path.unit_circle()
+ spine_type = 'circle'
+ result = cls(axes,spine_type,path,**kwargs)
+ result.set_patch_circle(center,radius)
+ return result
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <as...@us...> - 2009-06-01 21:41:46
|
Revision: 7168
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7168&view=rev
Author: astraw
Date: 2009-06-01 21:41:21 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
add cla() support for spines
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/spines.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-06-01 17:19:05 UTC (rev 7167)
+++ trunk/matplotlib/CHANGELOG 2009-06-01 21:41:21 UTC (rev 7168)
@@ -1,3 +1,5 @@
+2009-06-01 cla() support for spines - ADS
+
2009-06-01 Removed support for gtk < 2.4. - EF
2009-05-29 Improved the animation_blit_qt4 example, which was a mix
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-06-01 17:19:05 UTC (rev 7167)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-06-01 21:41:21 UTC (rev 7168)
@@ -906,6 +906,8 @@
# Note: this is called by Axes.__init__()
self.xaxis.cla()
self.yaxis.cla()
+ for name,spine in self.spines.iteritems():
+ spine.cla()
self.ignore_existing_data_limits = True
self.callbacks = cbook.CallbackRegistry(('xlim_changed',
Modified: trunk/matplotlib/lib/matplotlib/spines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/spines.py 2009-06-01 17:19:05 UTC (rev 7167)
+++ trunk/matplotlib/lib/matplotlib/spines.py 2009-06-01 21:41:21 UTC (rev 7168)
@@ -69,6 +69,12 @@
if self.axis is not None:
self.axis.cla()
+ def cla(self):
+ 'Clear the current spine'
+ self._position = None # clear position
+ if self.axis is not None:
+ self.axis.cla()
+
@allow_rasterization
def draw(self,renderer):
"draw everything that belongs to the spine"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-06-01 17:19:13
|
Revision: 7167
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7167&view=rev
Author: efiring
Date: 2009-06-01 17:19:05 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
Update CHANGELOG for removal of old gtk support.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-06-01 17:16:06 UTC (rev 7166)
+++ trunk/matplotlib/CHANGELOG 2009-06-01 17:19:05 UTC (rev 7167)
@@ -1,4 +1,6 @@
-2009-05-29 Improved the animation_blit_qt4 example, which was a mix
+2009-06-01 Removed support for gtk < 2.4. - EF
+
+2009-05-29 Improved the animation_blit_qt4 example, which was a mix
of the object-oriented and pylab interfaces. It is now
strictly object-oriented - DSD
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-06-01 17:16:28
|
Revision: 7166
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7166&view=rev
Author: efiring
Date: 2009-06-01 17:16:06 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
Removed support for gtk < 2.4
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2009-05-29 21:45:55 UTC (rev 7165)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2009-06-01 17:16:06 UTC (rev 7166)
@@ -10,7 +10,7 @@
except ImportError:
raise ImportError("Gtk* backend requires pygtk to be installed.")
-pygtk_version_required = (2,2,0)
+pygtk_version_required = (2,4,0)
if gtk.pygtk_version < pygtk_version_required:
raise ImportError ("PyGTK %d.%d.%d is installed\n"
"PyGTK %d.%d.%d or later is required"
@@ -606,37 +606,9 @@
def _init_toolbar(self):
self.set_style(gtk.TOOLBAR_ICONS)
+ self._init_toolbar2_4()
- if gtk.pygtk_version >= (2,4,0):
- self._init_toolbar2_4()
- else:
- self._init_toolbar2_2()
-
- def _init_toolbar2_2(self):
- basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
-
- for text, tooltip_text, image_file, callback in self.toolitems:
- if text is None:
- self.append_space()
- continue
-
- fname = os.path.join(basedir, image_file)
- image = gtk.Image()
- image.set_from_file(fname)
- w = self.append_item(text,
- tooltip_text,
- 'Private',
- image,
- getattr(self, callback)
- )
-
- self.append_space()
-
- self.message = gtk.Label()
- self.append_widget(self.message, None, None)
- self.message.show()
-
def _init_toolbar2_4(self):
basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
self.tooltips = gtk.Tooltips()
@@ -668,15 +640,11 @@
self.show_all()
def get_filechooser(self):
- if gtk.pygtk_version >= (2,4,0):
- return FileChooserDialog(
- title='Save the figure',
- parent=self.win,
- filetypes=self.canvas.get_supported_filetypes(),
- default_filetype=self.canvas.get_default_filetype())
- else:
- return FileSelection(title='Save the figure',
- parent=self.win,)
+ return FileChooserDialog(
+ title='Save the figure',
+ parent=self.win,
+ filetypes=self.canvas.get_supported_filetypes(),
+ default_filetype=self.canvas.get_default_filetype())
def save_figure(self, button):
fname, format = self.get_filechooser().get_filename_from_user()
@@ -768,19 +736,13 @@
self.set_style(gtk.TOOLBAR_ICONS)
- if gtk.pygtk_version >= (2,4,0):
- self._create_toolitems_2_4()
- self.update = self._update_2_4
- self.fileselect = FileChooserDialog(
- title='Save the figure',
- parent=self.win,
- filetypes=self.canvas.get_supported_filetypes(),
- default_filetype=self.canvas.get_default_filetype())
- else:
- self._create_toolitems_2_2()
- self.update = self._update_2_2
- self.fileselect = FileSelection(title='Save the figure',
- parent=self.win)
+ self._create_toolitems_2_4()
+ self.update = self._update_2_4
+ self.fileselect = FileChooserDialog(
+ title='Save the figure',
+ parent=self.win,
+ filetypes=self.canvas.get_supported_filetypes(),
+ default_filetype=self.canvas.get_default_filetype())
self.show_all()
self.update()
@@ -860,46 +822,6 @@
self.set_active(range(len(self._axes)))
- def _create_toolitems_2_2(self):
- # use the GTK+ 2.2 (and lower) GtkToolbar API
- iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR
-
- for text, tooltip_text, image_num, callback, callback_arg, scroll \
- in self.toolitems:
- if text is None:
- self.append_space()
- continue
- image = gtk.Image()
- image.set_from_stock(image_num, iconSize)
- item = self.append_item(text, tooltip_text, 'Private', image,
- getattr(self, callback), callback_arg)
- if scroll:
- item.connect("scroll_event", getattr(self, callback))
-
- self.omenu = gtk.OptionMenu()
- self.omenu.set_border_width(3)
- self.insert_widget(
- self.omenu,
- 'Select axes that controls affect',
- 'Private', 0)
-
-
- def _update_2_2(self):
- # for GTK+ 2.2 and lower
- # called by __init__() and FigureManagerGTK
-
- self._axes = self.canvas.figure.axes
-
- if len(self._axes) >= 2:
- # set up the axis menu
- self.omenu.set_menu( self._make_axis_menu() )
- self.omenu.show_all()
- else:
- self.omenu.hide()
-
- self.set_active(range(len(self._axes)))
-
-
def _make_axis_menu(self):
# called by self._update*()
@@ -969,15 +891,11 @@
return True
def get_filechooser(self):
- if gtk.pygtk_version >= (2,4,0):
- return FileChooserDialog(
- title='Save the figure',
- parent=self.win,
- filetypes=self.canvas.get_supported_filetypes(),
- default_filetype=self.canvas.get_default_filetype())
- else:
- return FileSelection(title='Save the figure',
- parent=self.win)
+ return FileChooserDialog(
+ title='Save the figure',
+ parent=self.win,
+ filetypes=self.canvas.get_supported_filetypes(),
+ default_filetype=self.canvas.get_default_filetype())
def save_figure(self, button):
fname, format = self.get_filechooser().get_filename_from_user()
@@ -988,112 +906,81 @@
error_msg_gtk(str(e), parent=self)
-if gtk.pygtk_version >= (2,4,0):
- class FileChooserDialog(gtk.FileChooserDialog):
- """GTK+ 2.4 file selector which remembers the last file/directory
- selected and presents the user with a menu of supported image formats
- """
- def __init__ (self,
- title = 'Save file',
- parent = None,
- action = gtk.FILE_CHOOSER_ACTION_SAVE,
- buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_SAVE, gtk.RESPONSE_OK),
- path = None,
- filetypes = [],
- default_filetype = None
- ):
- super (FileChooserDialog, self).__init__ (title, parent, action,
- buttons)
- self.set_default_response (gtk.RESPONSE_OK)
+class FileChooserDialog(gtk.FileChooserDialog):
+ """GTK+ 2.4 file selector which remembers the last file/directory
+ selected and presents the user with a menu of supported image formats
+ """
+ def __init__ (self,
+ title = 'Save file',
+ parent = None,
+ action = gtk.FILE_CHOOSER_ACTION_SAVE,
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_SAVE, gtk.RESPONSE_OK),
+ path = None,
+ filetypes = [],
+ default_filetype = None
+ ):
+ super (FileChooserDialog, self).__init__ (title, parent, action,
+ buttons)
+ self.set_default_response (gtk.RESPONSE_OK)
- if not path: path = os.getcwd() + os.sep
+ if not path: path = os.getcwd() + os.sep
- # create an extra widget to list supported image formats
- self.set_current_folder (path)
- self.set_current_name ('image.' + default_filetype)
+ # create an extra widget to list supported image formats
+ self.set_current_folder (path)
+ self.set_current_name ('image.' + default_filetype)
- hbox = gtk.HBox (spacing=10)
- hbox.pack_start (gtk.Label ("File Format:"), expand=False)
+ hbox = gtk.HBox (spacing=10)
+ hbox.pack_start (gtk.Label ("File Format:"), expand=False)
- liststore = gtk.ListStore(gobject.TYPE_STRING)
- cbox = gtk.ComboBox(liststore)
- cell = gtk.CellRendererText()
- cbox.pack_start(cell, True)
- cbox.add_attribute(cell, 'text', 0)
- hbox.pack_start (cbox)
+ liststore = gtk.ListStore(gobject.TYPE_STRING)
+ cbox = gtk.ComboBox(liststore)
+ cell = gtk.CellRendererText()
+ cbox.pack_start(cell, True)
+ cbox.add_attribute(cell, 'text', 0)
+ hbox.pack_start (cbox)
- self.filetypes = filetypes
- self.sorted_filetypes = filetypes.items()
- self.sorted_filetypes.sort()
- default = 0
- for i, (ext, name) in enumerate(self.sorted_filetypes):
- cbox.append_text ("%s (*.%s)" % (name, ext))
- if ext == default_filetype:
- default = i
- cbox.set_active(default)
- self.ext = default_filetype
+ self.filetypes = filetypes
+ self.sorted_filetypes = filetypes.items()
+ self.sorted_filetypes.sort()
+ default = 0
+ for i, (ext, name) in enumerate(self.sorted_filetypes):
+ cbox.append_text ("%s (*.%s)" % (name, ext))
+ if ext == default_filetype:
+ default = i
+ cbox.set_active(default)
+ self.ext = default_filetype
- def cb_cbox_changed (cbox, data=None):
- """File extension changed"""
- head, filename = os.path.split(self.get_filename())
- root, ext = os.path.splitext(filename)
- ext = ext[1:]
- new_ext = self.sorted_filetypes[cbox.get_active()][0]
- self.ext = new_ext
+ def cb_cbox_changed (cbox, data=None):
+ """File extension changed"""
+ head, filename = os.path.split(self.get_filename())
+ root, ext = os.path.splitext(filename)
+ ext = ext[1:]
+ new_ext = self.sorted_filetypes[cbox.get_active()][0]
+ self.ext = new_ext
- if ext in self.filetypes:
- filename = root + '.' + new_ext
- elif ext == '':
- filename = filename.rstrip('.') + '.' + new_ext
+ if ext in self.filetypes:
+ filename = root + '.' + new_ext
+ elif ext == '':
+ filename = filename.rstrip('.') + '.' + new_ext
- self.set_current_name (filename)
- cbox.connect ("changed", cb_cbox_changed)
+ self.set_current_name (filename)
+ cbox.connect ("changed", cb_cbox_changed)
- hbox.show_all()
- self.set_extra_widget(hbox)
+ hbox.show_all()
+ self.set_extra_widget(hbox)
- def get_filename_from_user (self):
- while True:
- filename = None
- if self.run() != int(gtk.RESPONSE_OK):
- break
- filename = self.get_filename()
+ def get_filename_from_user (self):
+ while True:
+ filename = None
+ if self.run() != int(gtk.RESPONSE_OK):
break
+ filename = self.get_filename()
+ break
- self.hide()
- return filename, self.ext
-else:
- class FileSelection(gtk.FileSelection):
- """GTK+ 2.2 and lower file selector which remembers the last
- file/directory selected
- """
- def __init__(self, path=None, title='Select a file', parent=None):
- super(FileSelection, self).__init__(title)
+ self.hide()
+ return filename, self.ext
- if path: self.path = path
- else: self.path = os.getcwd() + os.sep
-
- if parent: self.set_transient_for(parent)
-
- def get_filename_from_user(self, path=None, title=None):
- if path: self.path = path
- if title: self.set_title(title)
- self.set_filename(self.path)
-
- filename = None
- if self.run() == int(gtk.RESPONSE_OK):
- self.path = filename = self.get_filename()
- self.hide()
-
- ext = None
- if filename is not None:
- ext = os.path.splitext(filename)[1]
- if ext.startswith('.'):
- ext = ext[1:]
- return filename, ext
-
-
class DialogLineprops:
"""
A GUI dialog for controlling lineprops
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2009-05-29 21:46:20
|
Revision: 7165
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7165&view=rev
Author: dsdale
Date: 2009-05-29 21:45:55 +0000 (Fri, 29 May 2009)
Log Message:
-----------
improve the animation_blit_qt4 example
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/examples/animation/animation_blit_qt4.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-05-29 18:24:46 UTC (rev 7164)
+++ trunk/matplotlib/CHANGELOG 2009-05-29 21:45:55 UTC (rev 7165)
@@ -1,3 +1,7 @@
+2009-05-29 Improved the animation_blit_qt4 example, which was a mix
+ of the object-oriented and pylab interfaces. It is now
+ strictly object-oriented - DSD
+
2009-05-28 Fix axes_grid toolkit to work with spine patch by ADS. - JJL
2009-05-28 Applied fbianco's patch to handle scroll wheel events in
Modified: trunk/matplotlib/examples/animation/animation_blit_qt4.py
===================================================================
--- trunk/matplotlib/examples/animation/animation_blit_qt4.py 2009-05-29 18:24:46 UTC (rev 7164)
+++ trunk/matplotlib/examples/animation/animation_blit_qt4.py 2009-05-29 21:45:55 UTC (rev 7165)
@@ -1,68 +1,75 @@
# For detailed comments on animation and the techniqes used here, see
# the wiki entry http://www.scipy.org/Cookbook/Matplotlib/Animations
-import os, sys
-import matplotlib
-matplotlib.use('Qt4Agg') # qt4 example
+import os
+import sys
+#import matplotlib
+#matplotlib.use('Qt4Agg')
+from matplotlib.figure import Figure
+from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
+
from PyQt4 import QtCore, QtGui
ITERS = 1000
-import pylab as p
-import numpy as npy
+import numpy as np
import time
-class BlitQT(QtCore.QObject):
+class BlitQT(FigureCanvas):
+
def __init__(self):
- self.ax = p.subplot(111)
- self.canvas = self.ax.figure.canvas
+ FigureCanvas.__init__(self, Figure())
- # By making this a child of the canvas we make sure that it is
- # destroyed first and avoids a possible exception when the user clicks
- # on the window's close box.
- QtCore.QObject.__init__(self, self.canvas)
+ self.ax = self.figure.add_subplot(111)
+ self.ax.grid()
+ self.draw()
+ self.old_size = self.ax.bbox.width, self.ax.bbox.height
+ self.ax_background = self.copy_from_bbox(self.ax.bbox)
self.cnt = 0
- # create the initial line
- self.x = npy.arange(0,2*npy.pi,0.01)
- self.line, = p.plot(self.x, npy.sin(self.x), animated=True, lw=2)
+ self.x = np.arange(0,2*np.pi,0.01)
+ self.sin_line, = self.ax.plot(self.x, np.sin(self.x), animated=True)
+ self.cos_line, = self.ax.plot(self.x, np.cos(self.x), animated=True)
+ self.draw()
- self.background = None
- self.old_size = 0, 0
+ self.tstart = time.time()
+ self.startTimer(10)
def timerEvent(self, evt):
- # See if the size has changed since last time round.
current_size = self.ax.bbox.width, self.ax.bbox.height
-
if self.old_size != current_size:
self.old_size = current_size
- self.background = self.canvas.copy_from_bbox(self.ax.bbox)
+ self.ax.clear()
+ self.ax.grid()
+ self.draw()
+ self.ax_background = self.copy_from_bbox(self.ax.bbox)
- # restore the clean slate background
- self.canvas.restore_region(self.background)
+ self.restore_region(self.ax_background, bbox=self.ax.bbox)
+
# update the data
- self.line.set_ydata(npy.sin(self.x+self.cnt/10.0))
+ self.sin_line.set_ydata(np.sin(self.x+self.cnt/10.0))
+ self.cos_line.set_ydata(np.cos(self.x+self.cnt/10.0))
# just draw the animated artist
- self.ax.draw_artist(self.line)
+ self.ax.draw_artist(self.sin_line)
+ self.ax.draw_artist(self.cos_line)
# just redraw the axes rectangle
- self.canvas.blit(self.ax.bbox)
+ self.blit(self.ax.bbox)
+ if self.cnt == 0:
+ # TODO: this shouldn't be necessary, but if it is excluded the
+ # canvas outside the axes is not initially painted.
+ self.draw()
if self.cnt==ITERS:
# print the timing info and quit
print 'FPS:' , ITERS/(time.time()-self.tstart)
sys.exit()
-
else:
self.cnt += 1
-p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
-p.grid() # to ensure proper background restore
+app = QtGui.QApplication(sys.argv)
+widget = BlitQT()
+widget.show()
-app = BlitQT()
-# for profiling
-app.tstart = time.time()
-app.startTimer(0)
-
-p.show()
+sys.exit(app.exec_())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-05-29 18:24:55
|
Revision: 7164
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7164&view=rev
Author: efiring
Date: 2009-05-29 18:24:46 +0000 (Fri, 29 May 2009)
Log Message:
-----------
Make rcsetup validate_color handle non-string input
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/rcsetup.py
Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py 2009-05-29 15:59:47 UTC (rev 7163)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2009-05-29 18:24:46 UTC (rev 7164)
@@ -177,8 +177,11 @@
def validate_color(s):
'return a valid color arg'
- if s.lower() == 'none':
- return 'None'
+ try:
+ if s.lower() == 'none':
+ return 'None'
+ except AttributeError:
+ pass
if is_color_like(s):
return s
stmp = '#' + s
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-05-29 15:59:48
|
Revision: 7163
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7163&view=rev
Author: jdh2358
Date: 2009-05-29 15:59:47 +0000 (Fri, 29 May 2009)
Log Message:
-----------
fixed a buglet in legend when len(handles)==1 and ncol=2
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2009-05-29 03:52:32 UTC (rev 7162)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2009-05-29 15:59:47 UTC (rev 7163)
@@ -110,7 +110,7 @@
mode=None, # mode for horizontal distribution of columns. None, "expand"
fancybox=None, # True use a fancy box, false use a rounded box, none use rc
- shadow = None,
+ shadow = None,
title = None, # set a title for the legend
bbox_to_anchor = None, # bbox that the legend will be anchored.
bbox_transform = None, # transform for the bbox
@@ -139,7 +139,7 @@
borderaxespad the pad between the axes and legend border
columnspacing the spacing between columns
title the legend title
- bbox_to_anchor the bbox that the legend will be anchored.
+ bbox_to_anchor the bbox that the legend will be anchored.
bbox_transform the transform for the bbox. transAxes if None.
================ ==================================================================
@@ -204,6 +204,9 @@
del localdict
+ handles = list(handles)
+ if len(handles)<2:
+ ncol = 1
self._ncol = ncol
if self.numpoints <= 0:
@@ -258,7 +261,7 @@
self._loc = loc
self._mode = mode
self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform)
-
+
# We use FancyBboxPatch to draw a legend frame. The location
# and size of the box will be updated during the drawing time.
self.legendPatch = FancyBboxPatch(
@@ -578,13 +581,13 @@
sep = self.columnspacing*fontsize
- self._legend_handle_box = HPacker(pad=0,
+ self._legend_handle_box = HPacker(pad=0,
sep=sep, align="baseline",
mode=mode,
children=columnbox)
self._legend_title_box = TextArea("")
-
+
self._legend_box = VPacker(pad=self.borderpad*fontsize,
sep=self.labelspacing*fontsize,
align="center",
@@ -722,9 +725,9 @@
self._bbox_to_anchor = TransformedBbox(self._bbox_to_anchor,
transform)
-
-
+
+
def _get_anchored_bbox(self, loc, bbox, parentbbox, renderer):
"""
Place the *bbox* inside the *parentbbox* according to a given
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|