SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

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
S M T W T F S


1
(10)
2
(6)
3
4
(10)
5
(5)
6
(5)
7
(6)
8
(2)
9
(5)
10
(7)
11
(5)
12
(8)
13
(5)
14
(7)
15
(3)
16
(1)
17
(1)
18
19
(1)
20
(6)
21
(6)
22
(3)
23
(3)
24
(7)
25
26
(5)
27
(1)
28
(3)
29
(2)
30
(3)



Showing results of 126

<< < 1 2 3 4 .. 6 > >> (Page 2 of 6)
Revision: 8455
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8455&view=rev
Author: mdboom
Date: 2010年06月22日 16:30:24 +0000 (2010年6月22日)
Log Message:
-----------
Debian Bug#585442: python-matplotlib: crashes when calling axis() after imshow()
This allows the C++ exception raised when Agg rendering complexity is exceeded to percolate up correctly to a Python exception, rather than crashing the interpreter.
Fixes problem in last commit.
Modified Paths:
--------------
 trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h
Modified: trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h
===================================================================
--- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h	2010年06月22日 16:00:55 UTC (rev 8454)
+++ trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h	2010年06月22日 16:30:24 UTC (rev 8455)
@@ -179,16 +179,15 @@
 template<class Cell>
 AGG_INLINE void rasterizer_cells_aa<Cell>::add_curr_cell()
 {
- static Py::Exception e(
- Py::OverflowError(
- "Agg rendering complexity exceeded. Consider downsampling or decimating your data."));
-
-
 if(m_curr_cell.area | m_curr_cell.cover)
 {
 if((m_num_cells & cell_block_mask) == 0)
 {
 if(m_num_blocks >= cell_block_limit) {
+ static Py::Exception e(
+ Py::OverflowError(
+ "Agg rendering complexity exceeded. Consider downsampling or decimating your data."));
+
 /* If this exception is thrown too often, one can
 increase cell_block_limit */
 throw e;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8454
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8454&view=rev
Author: mdboom
Date: 2010年06月22日 16:00:55 +0000 (2010年6月22日)
Log Message:
-----------
Debian Bug#585442: python-matplotlib: crashes when calling axis() after imshow()
This allows the C++ exception raised when Agg rendering complexity is exceeded to percolate up correctly to a Python exception, rather than crashing the interpreter.
Modified Paths:
--------------
 trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h
Modified: trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h
===================================================================
--- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h	2010年06月21日 21:41:19 UTC (rev 8453)
+++ trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h	2010年06月22日 16:00:55 UTC (rev 8454)
@@ -29,16 +29,15 @@
 #ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
 #define AGG_RASTERIZER_CELLS_AA_INCLUDED
 
+#include "CXX/Exception.hxx"
 #include <exception>
 #include <string.h>
 #include <math.h>
 #include "agg_math.h"
 #include "agg_array.h"
 
-
 namespace agg
 {
-
 //-----------------------------------------------------rasterizer_cells_aa
 // An internal class that implements the main rasterization algorithm.
 // Used in the rasterizer. Should not be used direcly.
@@ -180,6 +179,11 @@
 template<class Cell>
 AGG_INLINE void rasterizer_cells_aa<Cell>::add_curr_cell()
 {
+ static Py::Exception e(
+ Py::OverflowError(
+ "Agg rendering complexity exceeded. Consider downsampling or decimating your data."));
+
+
 if(m_curr_cell.area | m_curr_cell.cover)
 {
 if((m_num_cells & cell_block_mask) == 0)
@@ -187,8 +191,7 @@
 if(m_num_blocks >= cell_block_limit) {
 /* If this exception is thrown too often, one can
 increase cell_block_limit */
- throw "Agg rendering complexity exceeded. "
- "Consider downsampling or decimating your data.";
+ throw e;
 }
 allocate_block();
 }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月21日 21:41:25
Revision: 8453
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8453&view=rev
Author: efiring
Date: 2010年06月21日 21:41:19 +0000 (2010年6月21日)
Log Message:
-----------
tick_params: fixed errors in handling top, bottom, etc. kwargs.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2010年06月21日 20:53:22 UTC (rev 8452)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2010年06月21日 21:41:19 UTC (rev 8453)
@@ -2168,13 +2168,17 @@
 """
 if axis in ['x', 'both']:
 xkw = dict(kwargs)
- xkw.pop('top', None)
- xkw.pop('bottom', None)
+ xkw.pop('left', None)
+ xkw.pop('right', None)
+ xkw.pop('labelleft', None)
+ xkw.pop('labelright', None)
 self.xaxis.set_tick_params(**xkw)
 if axis in ['y', 'both']:
 ykw = dict(kwargs)
- ykw.pop('left', None)
- ykw.pop('right', None)
+ ykw.pop('top', None)
+ ykw.pop('bottom', None)
+ ykw.pop('labeltop', None)
+ ykw.pop('labelbottom', None)
 self.yaxis.set_tick_params(**ykw)
 
 def set_axis_off(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月21日 20:53:29
Revision: 8452
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8452&view=rev
Author: efiring
Date: 2010年06月21日 20:53:22 +0000 (2010年6月21日)
Log Message:
-----------
Let pcolor antialiasing default be controlled by patch.antialiasing.
See ticket 3017725. In most cases antialiasing is better than, or
nearly as good as, non-antialiasing. A note about artifacts is now
in the docstring.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2010年06月21日 20:37:27 UTC (rev 8451)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2010年06月21日 20:53:22 UTC (rev 8452)
@@ -6740,16 +6740,16 @@
 *shading*: [ 'flat' | 'faceted' ]
 If 'faceted', a black grid is drawn around each rectangle; if
 'flat', edges are not drawn. Default is 'flat', contrary to
- Matlab(TM).
+ Matlab.
 
 This kwarg is deprecated; please use 'edgecolors' instead:
- * shading='flat' -- edgecolors='None'
+ * shading='flat' -- edgecolors='none'
 * shading='faceted -- edgecolors='k'
 
- *edgecolors*: [ None | 'None' | color | color sequence]
+ *edgecolors*: [ None | 'none' | color | color sequence]
 If *None*, the rc setting is used by default.
 
- If 'None', edges will not be visible.
+ If 'none', edges will not be visible.
 
 An mpl color or sequence of colors will set the edge color
 
@@ -6805,6 +6805,16 @@
 :class:`~matplotlib.collection.PolyCollection` properties:
 
 %(PolyCollection)s
+
+ Note: the default *antialiaseds* is taken from
+ rcParams['patch.antialiased'], which defaults to *True*.
+ In some cases, particularly if *alpha* is 1,
+ you may be able to reduce rendering artifacts (light or
+ dark patch boundaries) by setting it to *False*. An
+ alternative it to set *edgecolors* to 'face'. Unfortunately,
+ there seems to be no single combination of parameters that
+ eliminates artifacts under all conditions.
+
 """
 
 if not self._hold: self.cla()
@@ -6850,19 +6860,22 @@
 axis=1)
 verts = xy.reshape((npoly, 5, 2))
 
- #verts = zip(zip(X1,Y1),zip(X2,Y2),zip(X3,Y3),zip(X4,Y4))
-
 C = compress(ravelmask, ma.filled(C[0:Ny-1,0:Nx-1]).ravel())
 
-
 if shading == 'faceted':
- edgecolors = (0,0,0,1),
- linewidths = (0.25,)
+ edgecolors = 'k',
 else:
- edgecolors = 'face'
- linewidths = (1.0,)
+ edgecolors = 'none'
+ linewidths = (0.25,)
+ # Not sure if we want to have the following, or just trap
+ # invalid kwargs and raise an exception.
+ if 'edgecolor' in kwargs:
+ kwargs['edgecolors'] = kwargs.pop('edgecolor')
+ if 'linewidth' in kwargs:
+ kwargs['linewidths'] = kwargs.pop('linewidth')
+ if 'antialiased' in kwargs:
+ kwargs['antialiaseds'] = kwargs.pop('antialiased')
 kwargs.setdefault('edgecolors', edgecolors)
- kwargs.setdefault('antialiaseds', (0,))
 kwargs.setdefault('linewidths', linewidths)
 
 collection = mcoll.PolyCollection(verts, **kwargs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8451
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8451&view=rev
Author: jswhit
Date: 2010年06月21日 20:37:27 +0000 (2010年6月21日)
Log Message:
-----------
add antialiased=True to pcolor call (SF bugs item #3019150)
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/ccsm_popgrid.py
Modified: trunk/toolkits/basemap/examples/ccsm_popgrid.py
===================================================================
--- trunk/toolkits/basemap/examples/ccsm_popgrid.py	2010年06月21日 14:33:58 UTC (rev 8450)
+++ trunk/toolkits/basemap/examples/ccsm_popgrid.py	2010年06月21日 20:37:27 UTC (rev 8451)
@@ -55,8 +55,9 @@
 map.fillcontinents(color='white')
 
 x, y = map(tlon,tlat)
-im = map.pcolor(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask),\
- shading='faceted',cmap=plt.cm.cool,vmin=0,vmax=0)
+im = map.pcolor(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask),
+ shading='faceted', antialiased=True, cmap=plt.cm.cool, 
+ vmin=0, vmax=0)
 # disclaimer: these are not really the grid cells because of the
 # way pcolor interprets the x and y args.
 plt.title('(A) CCSM POP Grid Cells')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2010年06月21日 14:34:04
Revision: 8450
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8450&view=rev
Author: mdboom
Date: 2010年06月21日 14:33:58 +0000 (2010年6月21日)
Log Message:
-----------
[3018374] Link to examples is hardcoded
Modified Paths:
--------------
 trunk/matplotlib/doc/_templates/layout.html
Modified: trunk/matplotlib/doc/_templates/layout.html
===================================================================
--- trunk/matplotlib/doc/_templates/layout.html	2010年06月21日 13:19:11 UTC (rev 8449)
+++ trunk/matplotlib/doc/_templates/layout.html	2010年06月21日 14:33:58 UTC (rev 8450)
@@ -4,7 +4,7 @@
 {% block rootrellink %}
 <li><a href="{{ pathto('index') }}">home</a>|&nbsp;</li>
 <li><a href="{{ pathto('search') }}">search</a>|&nbsp;</li>
- <li><a href="http://matplotlib.sf.net/examples/index.html">examples</a>|&nbsp;</li>
+ <li><a href="{{ pathto('examples/index') }}">examples</a>|&nbsp;</li>
 <li><a href="{{ pathto('gallery') }}">gallery</a>|&nbsp;</li>
 <li><a href="{{ pathto('contents') }}">docs</a> &raquo;</li>
 {% endblock %}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2010年06月21日 13:19:18
Revision: 8449
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8449&view=rev
Author: mdboom
Date: 2010年06月21日 13:19:11 +0000 (2010年6月21日)
Log Message:
-----------
[3015217] Don't add piwik code to html docs by default
This prevents the web browser from making remote http requests when browsing the docs locally.
Modified Paths:
--------------
 trunk/matplotlib/doc/_templates/layout.html
Modified: trunk/matplotlib/doc/_templates/layout.html
===================================================================
--- trunk/matplotlib/doc/_templates/layout.html	2010年06月21日 08:51:30 UTC (rev 8448)
+++ trunk/matplotlib/doc/_templates/layout.html	2010年06月21日 13:19:11 UTC (rev 8449)
@@ -13,17 +13,24 @@
 {% block relbar1 %}
 <!-- Piwik -->
 <script type="text/javascript">
-var pkBaseURL = (("https:" == document.location.protocol) ? "https://apps.sourceforge.net/piwik/matplotlib/" : "http://apps.sourceforge.net/piwik/matplotlib/");
-document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
-</script><script type="text/javascript">
-piwik_action_name = '';
-piwik_idsite = 1;
-piwik_url = pkBaseURL + "piwik.php";
-piwik_log(piwik_action_name, piwik_idsite, piwik_url);
+if ("matplotlib.sourceforge.net" == document.location.hostname ||
+ "matplotlib.sf.net" == document.location.hostname) {
+ var pkBaseURL = (("https:" == document.location.protocol) ? "https://apps.sourceforge.net/piwik/matplotlib/" : "http://apps.sourceforge.net/piwik/matplotlib/");
+ document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
+}
 </script>
-<object><noscript><p><img src="http://apps.sourceforge.net/piwik/matplotlib/piwik.php?idsite=1" alt="piwik"/></p></noscript></object>
+<script type="text/javascript">
+if ("matplotlib.sourceforge.net" == document.location.hostname ||
+ "matplotlib.sf.net" == document.location.hostname) {
+ piwik_action_name = '';
+ piwik_idsite = 1;
+ piwik_url = pkBaseURL + "piwik.php";
+ piwik_log(piwik_action_name, piwik_idsite, piwik_url);
+ document.write(unescape('%3Cobject%3E%3Cnoscript%3E%3Cp%3E%3Cimg src="http://apps.sourceforge.net/piwik/matplotlib/piwik.php?idsite=1" alt="piwik"/%3E%3C/p%3E%3C/noscript%3E%3C/object%3E'));
+}
+</script>
 <!-- End Piwik Tag -->
-<link rel="shortcut icon" href="_static/favicon.ico"> 
+<link rel="shortcut icon" href="_static/favicon.ico">
 
 <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
 <a href="{{ pathto('index') }}"><img src="{{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月21日 08:51:37
Revision: 8448
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8448&view=rev
Author: efiring
Date: 2010年06月21日 08:51:30 +0000 (2010年6月21日)
Log Message:
-----------
Add Axes.tick_params and pyplot.tick_params to control tick and tick label appearance.
This allows interactive modification of tick and tick label color, size, etc.
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/boilerplate.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/axis.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2010年06月20日 23:31:49 UTC (rev 8447)
+++ trunk/matplotlib/CHANGELOG	2010年06月21日 08:51:30 UTC (rev 8448)
@@ -1,3 +1,7 @@
+2010年06月20日 Added Axes.tick_params and corresponding pyplot function
+ to control tick and tick label appearance after an Axes
+ has been created. - EF
+
 2010年06月09日 Allow Axes.grid to control minor gridlines; allow
 Axes.grid and Axis.grid to control major and minor
 gridlines in the same method call. - EF
Modified: trunk/matplotlib/boilerplate.py
===================================================================
--- trunk/matplotlib/boilerplate.py	2010年06月20日 23:31:49 UTC (rev 8447)
+++ trunk/matplotlib/boilerplate.py	2010年06月21日 08:51:30 UTC (rev 8448)
@@ -107,6 +107,7 @@
 'annotate',
 'ticklabel_format',
 'locator_params',
+ 'tick_params',
 'margins',
 )
 
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2010年06月20日 23:31:49 UTC (rev 8447)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2010年06月21日 08:51:30 UTC (rev 8448)
@@ -2101,7 +2101,82 @@
 self.yaxis.get_major_locator().set_params(**kwargs)
 self.autoscale_view(tight=tight, scalex=_x, scaley=_y)
 
+ def tick_params(self, axis='both', **kwargs):
+ """
+ Convenience method for changing the appearance of ticks and
+ tick labels.
 
+ Keyword arguments:
+
+ *axis*
+ ['x' | 'y' | 'both'] Axis on which to operate;
+ default is 'both'.
+
+ *reset*
+ [True | False] If *True*, set all parameters to defaults
+ before processing other keyword arguments. Default is
+ *False*.
+
+ *which*
+ ['major' | 'minor' | 'both'] Default is 'major': apply
+ arguments to major ticks only.
+
+ *direction*
+ ['in' | 'out'] Puts ticks inside or outside the axes.
+
+ *length*
+ Tick length in points.
+
+ *width*
+ Tick width in points.
+
+ *color*
+ Tick color; accepts any mpl color spec.
+
+ *pad*
+ Distance in points between tick and label.
+
+ *labelsize*
+ Tick label font size in points or as a string (e.g. 'large').
+
+ *labelcolor*
+ Tick label color; mpl color spec.
+
+ *colors*
+ Changes the tick color and the label color to the same value:
+ mpl color spec.
+
+ *zorder*
+ Tick and label zorder.
+
+ *bottom*, *top*, *left*, *right*
+ Boolean or ['on' | 'off'], controls whether to draw the
+ respective ticks.
+
+ *labelbottom*, *labeltop*, *labelleft*, *labelright*
+ Boolean or ['on' | 'off'], controls whether to draw the
+ respective tick labels.
+
+ Example::
+
+ ax.tick_params(direction='out', length=6, width=2, colors='r')
+
+ This will make all major ticks be red, pointing out of the box,
+ and with dimensions 6 points by 2 points. Tick labels will
+ also be red.
+
+ """
+ if axis in ['x', 'both']:
+ xkw = dict(kwargs)
+ xkw.pop('top', None)
+ xkw.pop('bottom', None)
+ self.xaxis.set_tick_params(**xkw)
+ if axis in ['y', 'both']:
+ ykw = dict(kwargs)
+ ykw.pop('left', None)
+ ykw.pop('right', None)
+ self.yaxis.set_tick_params(**ykw)
+
 def set_axis_off(self):
 """turn off the axis"""
 self.axison = False
Modified: trunk/matplotlib/lib/matplotlib/axis.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis.py	2010年06月20日 23:31:49 UTC (rev 8447)
+++ trunk/matplotlib/lib/matplotlib/axis.py	2010年06月21日 08:51:30 UTC (rev 8448)
@@ -60,7 +60,16 @@
 
 """
 def __init__(self, axes, loc, label,
- size = None, # points
+
+ size = None, # points
+ width = None,
+ color = None,
+ tickdir = None,
+ pad = None,
+ labelsize = None,
+ labelcolor = None,
+ zorder = None,
+
 gridOn = None, # defaults to axes.grid
 tick1On = True,
 tick2On = True,
@@ -71,7 +80,7 @@
 """
 bbox is the Bound2D bounding box in display coords of the Axes
 loc is the tick location in data coords
- size is the tick size in relative, axes coords
+ size is the tick size in points
 """
 artist.Artist.__init__(self)
 
@@ -81,27 +90,47 @@
 self.axes = axes
 
 name = self.__name__.lower()
+ self._name = name
+
+ self._loc = loc
+
 if size is None:
 if major:
 size = rcParams['%s.major.size'%name]
+ else:
+ size = rcParams['%s.minor.size'%name]
+ self._size = size
+
+ self._width = width # can be None for marker default
+
+ if color is None:
+ color = rcParams['%s.color' % name]
+ self._color = color
+
+ if pad is None:
+ if major:
 pad = rcParams['%s.major.pad'%name]
 else:
- size = rcParams['%s.minor.size'%name]
 pad = rcParams['%s.minor.pad'%name]
+ self._base_pad = pad
 
- self._tickdir = rcParams['%s.direction'%name]
- if self._tickdir == 'in':
- self._xtickmarkers = (mlines.TICKUP, mlines.TICKDOWN)
- self._ytickmarkers = (mlines.TICKRIGHT, mlines.TICKLEFT)
- self._pad = pad
- else:
- self._xtickmarkers = (mlines.TICKDOWN, mlines.TICKUP)
- self._ytickmarkers = (mlines.TICKLEFT, mlines.TICKRIGHT)
- self._pad = pad + size
+ if labelcolor is None:
+ labelcolor = rcParams['%s.color' % name]
+ self._labelcolor = labelcolor
 
- self._loc = loc
- self._size = size
+ if labelsize is None:
+ labelsize = rcParams['%s.labelsize' % name]
+ self._labelsize = labelsize
 
+ if zorder is None:
+ if major:
+ zorder = mlines.Line2D.zorder + 0.01
+ else:
+ zorder = mlines.Line2D.zorder
+ self._zorder = zorder
+
+ self.apply_tickdir(tickdir)
+
 self.tick1line = self._get_tick1line()
 self.tick2line = self._get_tick2line()
 self.gridline = self._get_gridline()
@@ -118,6 +147,20 @@
 
 self.update_position(loc)
 
+ def apply_tickdir(self, tickdir):
+ if tickdir is None:
+ tickdir = rcParams['%s.direction' % self._name]
+ self._tickdir = tickdir
+
+ if self._tickdir == 'in':
+ self._xtickmarkers = (mlines.TICKUP, mlines.TICKDOWN)
+ self._ytickmarkers = (mlines.TICKRIGHT, mlines.TICKLEFT)
+ self._pad = self._base_pad
+ else:
+ self._xtickmarkers = (mlines.TICKDOWN, mlines.TICKUP)
+ self._ytickmarkers = (mlines.TICKLEFT, mlines.TICKRIGHT)
+ self._pad = self._base_pad + self._size
+
 def get_children(self):
 children = [self.tick1line, self.tick2line, self.gridline, self.label1, self.label2]
 return children
@@ -242,15 +285,13 @@
 # x in data coords, y in axes coords
 #t = mtext.Text(
 trans, vert, horiz = self.axes.get_xaxis_text1_transform(self._pad)
- size = rcParams['xtick.labelsize']
 t = mtext.Text(
 x=0, y=0,
- fontproperties=font_manager.FontProperties(size=size),
- color=rcParams['xtick.color'],
+ fontproperties=font_manager.FontProperties(size=self._labelsize),
+ color=self._labelcolor,
 verticalalignment=vert,
 horizontalalignment=horiz,
 )
-
 t.set_transform(trans)
 self._set_artist_props(t)
 return t
@@ -262,11 +303,10 @@
 # x in data coords, y in axes coords
 #t = mtext.Text(
 trans, vert, horiz = self.axes.get_xaxis_text2_transform(self._pad)
-
 t = mtext.Text(
 x=0, y=1,
- fontproperties=font_manager.FontProperties(size=rcParams['xtick.labelsize']),
- color=rcParams['xtick.color'],
+ fontproperties=font_manager.FontProperties(size=self._labelsize),
+ color=self._labelcolor,
 verticalalignment=vert,
 horizontalalignment=horiz,
 )
@@ -278,10 +318,12 @@
 'Get the default line2D instance'
 # x in data coords, y in axes coords
 l = mlines.Line2D(xdata=(0,), ydata=(0,),
- color='k',
+ color=self._color,
 linestyle = 'None',
 marker = self._xtickmarkers[0],
 markersize=self._size,
+ markeredgewidth=self._width,
+ zorder=self._zorder,
 )
 l.set_transform(self.axes.get_xaxis_transform(which='tick1'))
 self._set_artist_props(l)
@@ -291,10 +333,12 @@
 'Get the default line2D instance'
 # x in data coords, y in axes coords
 l = mlines.Line2D( xdata=(0,), ydata=(1,),
- color='k',
+ color=self._color,
 linestyle = 'None',
 marker = self._xtickmarkers[1],
 markersize=self._size,
+ markeredgewidth=self._width,
+ zorder=self._zorder,
 )
 
 l.set_transform(self.axes.get_xaxis_transform(which='tick2'))
@@ -372,13 +416,11 @@
 def _get_text1(self):
 'Get the default Text instance'
 # x in axes coords, y in data coords
- #t = mtext.Text(
 trans, vert, horiz = self.axes.get_yaxis_text1_transform(self._pad)
-
 t = mtext.Text(
 x=0, y=0,
- fontproperties=font_manager.FontProperties(size=rcParams['ytick.labelsize']),
- color=rcParams['ytick.color'],
+ fontproperties=font_manager.FontProperties(size=self._labelsize),
+ color=self._labelcolor,
 verticalalignment=vert,
 horizontalalignment=horiz,
 )
@@ -390,13 +432,11 @@
 def _get_text2(self):
 'Get the default Text instance'
 # x in axes coords, y in data coords
- #t = mtext.Text(
 trans, vert, horiz = self.axes.get_yaxis_text2_transform(self._pad)
-
 t = mtext.Text(
 x=1, y=0,
- fontproperties=font_manager.FontProperties(size=rcParams['ytick.labelsize']),
- color=rcParams['ytick.color'],
+ fontproperties=font_manager.FontProperties(size=self._labelsize),
+ color=self._labelcolor,
 verticalalignment=vert,
 horizontalalignment=horiz,
 )
@@ -408,11 +448,14 @@
 'Get the default line2D instance'
 # x in axes coords, y in data coords
 
- l = mlines.Line2D( (0,), (0,), color='k',
+ l = mlines.Line2D( (0,), (0,),
+ color=self._color,
 marker = self._ytickmarkers[0],
 linestyle = 'None',
 markersize=self._size,
- )
+ markeredgewidth=self._width,
+ zorder=self._zorder,
+ )
 l.set_transform(self.axes.get_yaxis_transform(which='tick1'))
 self._set_artist_props(l)
 return l
@@ -420,12 +463,14 @@
 def _get_tick2line(self):
 'Get the default line2D instance'
 # x in axes coords, y in data coords
- l = mlines.Line2D( (1,), (0,), color='k',
+ l = mlines.Line2D( (1,), (0,),
+ color=self._color,
 marker = self._ytickmarkers[1],
 linestyle = 'None',
 markersize=self._size,
+ markeredgewidth=self._width,
+ zorder=self._zorder,
 )
-
 l.set_transform(self.axes.get_yaxis_transform(which='tick2'))
 self._set_artist_props(l)
 return l
@@ -549,6 +594,10 @@
 self.minorTicks = []
 self.pickradius = pickradius
 
+ # Initialize here for testing; later add API
+ self._major_tick_kw = dict()
+ self._minor_tick_kw = dict()
+
 self.cla()
 self.set_scale('linear')
 
@@ -631,10 +680,16 @@
 self.label.set_text('')
 self._set_artist_props(self.label)
 
+ self.reset_ticks()
+
+ self.converter = None
+ self.units = None
+ self.set_units(None)
+
+ def reset_ticks(self):
 # build a few default ticks; grow as necessary later; only
 # define 1 so properties set on ticks will be copied as they
 # grow
-
 cbook.popall(self.majorTicks)
 cbook.popall(self.minorTicks)
 
@@ -643,10 +698,84 @@
 self._lastNumMajorTicks = 1
 self._lastNumMinorTicks = 1
 
- self.converter = None
- self.units = None
- self.set_units(None)
+ def set_tick_params(self, which='major', reset=False, **kw):
+ """
+ Set appearance parameters for ticks and ticklabels.
 
+ For documentation of keyword arguments, see
+ :meth:`matplotlib.axes.Axes.tick_params`.
+ """
+ dicts = []
+ if which == 'major' or which == 'both':
+ dicts.append(self._major_tick_kw)
+ if which == 'minor' or which == 'both':
+ dicts.append(self._minor_tick_kw)
+ kwtrans = self._translate_tick_kw(kw, to_init_kw=True)
+ for d in dicts:
+ if reset:
+ d.clear()
+ d.update(kwtrans)
+ self.reset_ticks()
+
+ @staticmethod
+ def _translate_tick_kw(kw, to_init_kw=True):
+ # We may want to move the following function to
+ # a more visible location; or maybe there already
+ # is something like this.
+ def _bool(arg):
+ if cbook.is_string_like(arg):
+ if arg.lower() == 'on':
+ return True
+ if arg.lower() == 'off':
+ return False
+ raise ValueError('String "%s" should be "on" or "off"' % arg)
+ return bool(arg)
+ # The following lists may be moved to a more
+ # accessible location.
+ kwkeys0 = ['size', 'width', 'color', 'tickdir', 'pad',
+ 'labelsize', 'labelcolor', 'zorder',
+ 'tick1On', 'tick2On', 'label1On', 'label2On']
+ kwkeys1 = ['length', 'direction', 'left', 'bottom', 'right', 'top',
+ 'labelleft', 'labelbottom', 'labelright', 'labeltop']
+ kwkeys = kwkeys0 + kwkeys1
+ kwtrans = dict()
+ if to_init_kw:
+ if 'length' in kw:
+ kwtrans['size'] = kw.pop('length')
+ if 'direction' in kw:
+ kwtrans['tickdir'] = kw.pop('direction')
+ if 'left' in kw:
+ kwtrans['tick1On'] = _bool(kw.pop('left'))
+ if 'bottom' in kw:
+ kwtrans['tick1On'] = _bool(kw.pop('bottom'))
+ if 'right' in kw:
+ kwtrans['tick2On'] = _bool(kw.pop('right'))
+ if 'top' in kw:
+ kwtrans['tick2On'] = _bool(kw.pop('top'))
+
+ if 'labelleft' in kw:
+ kwtrans['label1On'] = _bool(kw.pop('labelleft'))
+ if 'labelbottom' in kw:
+ kwtrans['label1On'] = _bool(kw.pop('labelbottom'))
+ if 'labelright' in kw:
+ kwtrans['label2On'] = _bool(kw.pop('labelright'))
+ if 'labeltop' in kw:
+ kwtrans['label2On'] = _bool(kw.pop('labeltop'))
+ if 'colors' in kw:
+ c = kw.pop('colors')
+ kwtrans['color'] = c
+ kwtrans['labelcolor'] = c
+ # Maybe move the checking up to the caller of this method.
+ for key in kw:
+ if key not in kwkeys:
+ raise ValueError(
+ "keyword %s is not recognized; valid keywords are %s"
+ % (key, kwkeys))
+ kwtrans.update(kw)
+ else:
+ raise NotImplementedError("Inverse translation is deferred")
+ return kwtrans
+
 def set_clip_path(self, clippath, transform=None):
 artist.Artist.set_clip_path(self, clippath, transform)
 majorticks = self.get_major_ticks()
@@ -1303,13 +1432,18 @@
 return inaxis, {}
 
 def _get_tick(self, major):
- return XTick(self.axes, 0, '', major=major)
+ if major:
+ tick_kw = self._major_tick_kw
+ else:
+ tick_kw = self._minor_tick_kw
+ return XTick(self.axes, 0, '', major=major, **tick_kw)
 
 def _get_label(self):
 # x in axes coords, y in display coords (to be updated at draw
 # time by _update_label_positions)
 label = mtext.Text(x=0.5, y=0,
- fontproperties = font_manager.FontProperties(size=rcParams['axes.labelsize']),
+ fontproperties = font_manager.FontProperties(
+ size=rcParams['axes.labelsize']),
 color = rcParams['axes.labelcolor'],
 verticalalignment='top',
 horizontalalignment='center',
@@ -1325,7 +1459,8 @@
 def _get_offset_text(self):
 # x in axes coords, y in display coords (to be updated at draw time)
 offsetText = mtext.Text(x=1, y=0,
- fontproperties = font_manager.FontProperties(size=rcParams['xtick.labelsize']),
+ fontproperties = font_manager.FontProperties(
+ size=rcParams['xtick.labelsize']),
 color = rcParams['xtick.color'],
 verticalalignment='top',
 horizontalalignment='right',
@@ -1562,7 +1697,11 @@
 return inaxis, {}
 
 def _get_tick(self, major):
- return YTick(self.axes, 0, '', major=major)
+ if major:
+ tick_kw = self._major_tick_kw
+ else:
+ tick_kw = self._minor_tick_kw
+ return YTick(self.axes, 0, '', major=major, **tick_kw)
 
 
 def _get_label(self):
@@ -1570,7 +1709,8 @@
 # y in axes coords
 label = mtext.Text(x=0, y=0.5,
 # todo: get the label position
- fontproperties=font_manager.FontProperties(size=rcParams['axes.labelsize']),
+ fontproperties=font_manager.FontProperties(
+ size=rcParams['axes.labelsize']),
 color = rcParams['axes.labelcolor'],
 verticalalignment='center',
 horizontalalignment='right',
@@ -1586,7 +1726,8 @@
 def _get_offset_text(self):
 # x in display coords, y in axes coords (to be updated at draw time)
 offsetText = mtext.Text(x=0, y=0.5,
- fontproperties = font_manager.FontProperties(size=rcParams['ytick.labelsize']),
+ fontproperties = font_manager.FontProperties(
+ size=rcParams['ytick.labelsize']),
 color = rcParams['ytick.color'],
 verticalalignment = 'baseline',
 horizontalalignment = 'left',
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2010年06月20日 23:31:49 UTC (rev 8447)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2010年06月21日 08:51:30 UTC (rev 8448)
@@ -1936,8 +1936,7 @@
 # This function was autogenerated by boilerplate.py. Do not edit as
 # changes will be lost
 @autogen_docstring(Axes.boxplot)
-def boxplot(x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None,
- hold=None, patch_artist=False):
+def boxplot(x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None, patch_artist=False, bootstrap=None, hold=None):
 ax = gca()
 # allow callers to override the hold state by passing hold=True|False
 washold = ax.ishold()
@@ -1945,8 +1944,7 @@
 if hold is not None:
 ax.hold(hold)
 try:
- ret = ax.boxplot(x, notch, sym, vert, whis, positions, widths,
- patch_artist=patch_artist)
+ ret = ax.boxplot(x, notch, sym, vert, whis, positions, widths, patch_artist, bootstrap)
 draw_if_interactive()
 finally:
 ax.hold(washold)
@@ -2136,7 +2134,7 @@
 # This function was autogenerated by boilerplate.py. Do not edit as
 # changes will be lost
 @autogen_docstring(Axes.hist)
-def hist(x, bins=10, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, hold=None, **kwargs):
+def hist(x, bins=10, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, hold=None, **kwargs):
 ax = gca()
 # allow callers to override the hold state by passing hold=True|False
 washold = ax.ishold()
@@ -2144,7 +2142,7 @@
 if hold is not None:
 ax.hold(hold)
 try:
- ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, **kwargs)
+ ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, **kwargs)
 draw_if_interactive()
 finally:
 ax.hold(washold)
@@ -2421,7 +2419,6 @@
 sci(ret[-1])
 return ret
 
-
 # This function was autogenerated by boilerplate.py. Do not edit as
 # changes will be lost
 @autogen_docstring(Axes.stem)
@@ -2643,13 +2640,21 @@
 # This function was autogenerated by boilerplate.py. Do not edit as
 # changes will be lost
 @docstring.copy_dedent(Axes.locator_params)
-def locator_params(axis='both', tight=False, **kwargs):
+def locator_params(axis='both', tight=None, **kwargs):
 ret = gca().locator_params(axis, tight, **kwargs)
 draw_if_interactive()
 return ret
 
 # This function was autogenerated by boilerplate.py. Do not edit as
 # changes will be lost
+...@do...py_dedent(Axes.tick_params)
+def tick_params(axis='both', **kwargs):
+ ret = gca().tick_params(axis, **kwargs)
+ draw_if_interactive()
+ return ret
+
+# This function was autogenerated by boilerplate.py. Do not edit as
+# changes will be lost
 @docstring.copy_dedent(Axes.margins)
 def margins(*args, **kw):
 ret = gca().margins(*args, **kw)
@@ -2879,3 +2884,6 @@
 if im is not None:
 im.set_cmap(cm.spectral)
 draw_if_interactive()
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <lee...@us...> - 2010年06月20日 23:31:55
Revision: 8447
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8447&view=rev
Author: leejjoon
Date: 2010年06月20日 23:31:49 +0000 (2010年6月20日)
Log Message:
-----------
revert r8445,8446 and fix plot_directive.py to support sphinx 1.0
Modified Paths:
--------------
 trunk/matplotlib/doc/faq/howto_faq.rst
 trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
Modified: trunk/matplotlib/doc/faq/howto_faq.rst
===================================================================
--- trunk/matplotlib/doc/faq/howto_faq.rst	2010年06月20日 20:55:42 UTC (rev 8446)
+++ trunk/matplotlib/doc/faq/howto_faq.rst	2010年06月20日 23:31:49 UTC (rev 8447)
@@ -178,6 +178,9 @@
 of each of the labels and uses it to move the left of the subplots
 over so that the tick labels fit in the figure
 
+.. plot:: pyplots/auto_subplots_adjust.py
+ :include-source:
+
 .. _howto-ticks:
 
 Configure the tick linewidths
@@ -218,6 +221,9 @@
 below shows the default behavior in the left subplots, and the manual
 setting in the right subplots.
 
+.. plot:: pyplots/align_ylabels.py
+ :include-source:
+
 .. _date-index-plots:
 
 Skip dates where there is no data
Modified: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py	2010年06月20日 20:55:42 UTC (rev 8446)
+++ trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py	2010年06月20日 23:31:49 UTC (rev 8447)
@@ -366,8 +366,13 @@
 
 if options.has_key('include-source'):
 if plot_code is None:
+ if sphinx_version > (1,):
+ include_prefix = '/'
+ else:
+ include_prefix = setup.app.builder.srcdir
+
 lines.extend(
- ['.. include:: %s' % os.path.join(setup.app.builder.srcdir, plot_path),
+ ['.. include:: %s' % os.path.join(include_prefix, plot_path),
 ' :literal:'])
 if options.has_key('encoding'):
 lines.append(' :encoding: %s' % options['encoding'])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <lee...@us...> - 2010年06月20日 20:55:49
Revision: 8446
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8446&view=rev
Author: leejjoon
Date: 2010年06月20日 20:55:42 +0000 (2010年6月20日)
Log Message:
-----------
remove align_ylabels.py entry from howto_faq.rst to test doc-build
Modified Paths:
--------------
 trunk/matplotlib/doc/faq/howto_faq.rst
Modified: trunk/matplotlib/doc/faq/howto_faq.rst
===================================================================
--- trunk/matplotlib/doc/faq/howto_faq.rst	2010年06月20日 20:05:57 UTC (rev 8445)
+++ trunk/matplotlib/doc/faq/howto_faq.rst	2010年06月20日 20:55:42 UTC (rev 8446)
@@ -218,9 +218,6 @@
 below shows the default behavior in the left subplots, and the manual
 setting in the right subplots.
 
-.. plot:: pyplots/align_ylabels.py
- :include-source:
-
 .. _date-index-plots:
 
 Skip dates where there is no data
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <lee...@us...> - 2010年06月20日 20:06:03
Revision: 8445
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8445&view=rev
Author: leejjoon
Date: 2010年06月20日 20:05:57 +0000 (2010年6月20日)
Log Message:
-----------
remove auto_subplots_adjust.py entry from howto_faq.rst to test doc-build
Modified Paths:
--------------
 trunk/matplotlib/doc/faq/howto_faq.rst
Modified: trunk/matplotlib/doc/faq/howto_faq.rst
===================================================================
--- trunk/matplotlib/doc/faq/howto_faq.rst	2010年06月20日 20:05:49 UTC (rev 8444)
+++ trunk/matplotlib/doc/faq/howto_faq.rst	2010年06月20日 20:05:57 UTC (rev 8445)
@@ -178,9 +178,6 @@
 of each of the labels and uses it to move the left of the subplots
 over so that the tick labels fit in the figure
 
-.. plot:: pyplots/auto_subplots_adjust.py
- :include-source:
-
 .. _howto-ticks:
 
 Configure the tick linewidths
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8444
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8444&view=rev
Author: leejjoon
Date: 2010年06月20日 20:05:49 +0000 (2010年6月20日)
Log Message:
-----------
mpl_toolkits.axisartist.grid_finder.MaxNLocator supports factor
Modified Paths:
--------------
 trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py
Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py	2010年06月20日 16:46:34 UTC (rev 8443)
+++ trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py	2010年06月20日 20:05:49 UTC (rev 8444)
@@ -260,14 +260,22 @@
 trim=trim, integer=integer,
 symmetric=symmetric, prune=prune)
 self.create_dummy_axis()
+ self._factor = None
 
-
 def __call__(self, v1, v2):
- self.set_bounds(v1, v2)
- locs = mticker.MaxNLocator.__call__(self)
- return np.array(locs), len(locs), None
+ if self._factor is not None:
+ self.set_bounds(v1*self._factor, v2*self._factor)
+ locs = mticker.MaxNLocator.__call__(self)
+ return np.array(locs), len(locs), self._factor
+ else:
+ self.set_bounds(v1, v2)
+ locs = mticker.MaxNLocator.__call__(self)
+ return np.array(locs), len(locs), None
 
+ def set_factor(self, f):
+ self._factor = f
 
+
 class FixedLocator(object):
 def __init__(self, locs):
 self._locs = locs
@@ -287,11 +295,14 @@
 def __init__(self):
 self._fmt = mticker.ScalarFormatter()
 self._fmt.create_dummy_axis()
+ self._ignore_factor = True
 
 def __call__(self, direction, factor, values):
- if factor is None:
- factor = 1.
- values = [v/factor for v in values]
+ if not self._ignore_factor:
+ if factor is None:
+ factor = 1.
+ values = [v/factor for v in values]
+ #values = [v for v in values]
 self._fmt.set_locs(values)
 return [self._fmt(v) for v in values]
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月20日 16:46:40
Revision: 8443
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8443&view=rev
Author: efiring
Date: 2010年06月20日 16:46:34 +0000 (2010年6月20日)
Log Message:
-----------
finance: restore original adjustment algorithm, but use ndarray.
A numpy recarray replaces the Bunch when asobject is True.
Additional fields are provided.
Modified Paths:
--------------
 trunk/matplotlib/examples/pylab_examples/date_demo1.py
 trunk/matplotlib/examples/pylab_examples/date_demo2.py
 trunk/matplotlib/examples/pylab_examples/finance_demo.py
 trunk/matplotlib/lib/matplotlib/finance.py
Modified: trunk/matplotlib/examples/pylab_examples/date_demo1.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/date_demo1.py	2010年06月20日 01:34:30 UTC (rev 8442)
+++ trunk/matplotlib/examples/pylab_examples/date_demo1.py	2010年06月20日 16:46:34 UTC (rev 8443)
@@ -27,7 +27,7 @@
 
 quotes = quotes_historical_yahoo(
 'INTC', date1, date2)
-if not quotes:
+if len(quotes) == 0:
 raise SystemExit
 
 dates = [q[0] for q in quotes]
Modified: trunk/matplotlib/examples/pylab_examples/date_demo2.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/date_demo2.py	2010年06月20日 01:34:30 UTC (rev 8442)
+++ trunk/matplotlib/examples/pylab_examples/date_demo2.py	2010年06月20日 16:46:34 UTC (rev 8443)
@@ -23,7 +23,7 @@
 
 
 quotes = quotes_historical_yahoo('INTC', date1, date2)
-if not quotes:
+if len(quotes) == 0:
 print 'Found no quotes'
 raise SystemExit
 
Modified: trunk/matplotlib/examples/pylab_examples/finance_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/finance_demo.py	2010年06月20日 01:34:30 UTC (rev 8442)
+++ trunk/matplotlib/examples/pylab_examples/finance_demo.py	2010年06月20日 16:46:34 UTC (rev 8443)
@@ -5,20 +5,18 @@
 from matplotlib.finance import quotes_historical_yahoo, candlestick,\
 plot_day_summary, candlestick2
 
-import datetime
+# (Year, month, day) tuples suffice as args for quotes_historical_yahoo
+date1 = ( 2004, 2, 1)
+date2 = ( 2004, 4, 12 )
 
-date1 = datetime.date( 2004, 2, 1)
-date2 = datetime.date( 2004, 4, 12 )
 
-
 mondays = WeekdayLocator(MONDAY) # major ticks on the mondays
 alldays = DayLocator() # minor ticks on the days
 weekFormatter = DateFormatter('%b %d') # Eg, Jan 12
 dayFormatter = DateFormatter('%d') # Eg, 12
 
-quotes = quotes_historical_yahoo(
- 'INTC', date1, date2)
-if not quotes:
+quotes = quotes_historical_yahoo('INTC', date1, date2)
+if len(quotes) == 0:
 raise SystemExit
 
 fig = figure()
Modified: trunk/matplotlib/lib/matplotlib/finance.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/finance.py	2010年06月20日 01:34:30 UTC (rev 8442)
+++ trunk/matplotlib/lib/matplotlib/finance.py	2010年06月20日 16:46:34 UTC (rev 8443)
@@ -11,90 +11,130 @@
 from hashlib import md5
 except ImportError:
 from md5 import md5 #Deprecated in 2.5
+import datetime
 
-try: import datetime
-except ImportError:
- raise ImportError('The finance module requires datetime support (python2.3)')
-
 import numpy as np
 
 from matplotlib import verbose, get_configdir
-from dates import date2num
-from matplotlib.cbook import Bunch
+from matplotlib.dates import date2num
+from matplotlib.cbook import iterable, is_string_like
 from matplotlib.collections import LineCollection, PolyCollection
 from matplotlib.colors import colorConverter
-from lines import Line2D, TICKLEFT, TICKRIGHT
-from patches import Rectangle
+from matplotlib.lines import Line2D, TICKLEFT, TICKRIGHT
+from matplotlib.patches import Rectangle
 from matplotlib.transforms import Affine2D
 
 
-
 configdir = get_configdir()
 cachedir = os.path.join(configdir, 'finance.cache')
 
 
-def parse_yahoo_historical(fh, asobject=False, adjusted=True):
+stock_dt = np.dtype([('date', object),
+ ('year', np.int16),
+ ('month', np.int8),
+ ('day', np.int8),
+ ('d', np.float), # mpl datenum
+ ('open', np.float),
+ ('close', np.float),
+ ('high', np.float),
+ ('low', np.float),
+ ('volume', np.int),
+ ('aclose', np.float)])
+
+
+def parse_yahoo_historical(fh, adjusted=True, asobject=False):
 """
- Parse the historical data in file handle fh from yahoo finance and return
- results as a list of
+ Parse the historical data in file handle fh from yahoo finance.
 
- d, open, close, high, low, volume
+ *adjusted*
+ If True (default) replace open, close, high, low, and volume with
+ their adjusted values.
+ The adjustment is by a scale factor, S = adjusted_close/close.
+ Adjusted volume is actual volume divided by S;
+ Adjusted prices are actual prices multiplied by S. Hence,
+ the product of price and volume is unchanged by the adjustment.
 
- where d is a floating poing representation of date, as returned by date2num
+ *asobject*
+ If False (default for compatibility with earlier versions)
+ return a list of tuples containing
 
- if adjusted=True, use adjusted prices. Note that volume is not
- adjusted and we are not able to handle volume adjustments properly
- because the Yahoo CSV does not distinguish between split and
- dividend adjustments.
+ d, open, close, high, low, volume
+
+ If None (preferred alternative to False), return
+ a 2-D ndarray corresponding to the list of tuples.
+
+ Otherwise return a numpy recarray with
+
+ date, year, month, day, d, open, close, high, low,
+ volume, adjusted_close
+
+ where d is a floating poing representation of date,
+ as returned by date2num, and date is a python standard
+ library datetime.date instance.
+
+ The name of this kwarg is a historical artifact. Formerly,
+ True returned a cbook Bunch
+ holding 1-D ndarrays. The behavior of a numpy recarray is
+ very similar to the Bunch.
+
 """
- results = []
 
 lines = fh.readlines()
 
- datefmt = None
+ results = []
 
+ datefmt = '%Y-%m-%d'
+
 for line in lines[1:]:
 
 vals = line.split(',')
-
- if len(vals)!=7: continue
+ if len(vals)!=7:
+ continue # add warning?
 datestr = vals[0]
- if datefmt is None:
- try:
- datefmt = '%Y-%m-%d'
- dt = datetime.date(*time.strptime(datestr, datefmt)[:3])
- except ValueError:
- datefmt = '%d-%b-%y' # Old Yahoo--cached file?
- dt = datetime.date(*time.strptime(datestr, datefmt)[:3])
- d = date2num(dt)
+ #dt = datetime.date(*time.strptime(datestr, datefmt)[:3])
+ # Using strptime doubles the runtime. With the present
+ # format, we don't need it.
+ dt = datetime.date(*[int(val) for val in datestr.split('-')])
+ dnum = date2num(dt)
 open, high, low, close = [float(val) for val in vals[1:5]]
 volume = int(vals[5])
- if adjusted:
- aclose = float(vals[6])
- delta = aclose-close
- open += delta
- high += delta
- low += delta
- close = aclose
+ aclose = float(vals[6])
 
- results.append((d, open, close, high, low, volume))
+ results.append((dt, dt.year, dt.month, dt.day,
+ dnum, open, close, high, low, volume, aclose))
 results.reverse()
- if asobject:
- if len(results)==0: return None
- else:
- date, open, close, high, low, volume = map(np.asarray, zip(*results))
- return Bunch(date=date, open=open, close=close, high=high, low=low, volume=volume)
- else:
+ d = np.array(results, dtype=stock_dt)
+ if adjusted:
+ scale = d['aclose'] / d['close']
+ scale[np.isinf(scale)] = np.nan
+ d['open'] *= scale
+ d['close'] *= scale
+ d['high'] *= scale
+ d['low'] *= scale
 
- return results
+ if not asobject:
+ # 2-D sequence; formerly list of tuples, now ndarray
+ ret = np.zeros((len(d), 6), dtype=np.float)
+ ret[:,0] = d['d']
+ ret[:,1] = d['open']
+ ret[:,2] = d['close']
+ ret[:,3] = d['high']
+ ret[:,4] = d['low']
+ ret[:,5] = d['volume']
+ if asobject is None:
+ return ret
+ return [tuple(row) for row in ret]
 
+ return d.view(np.recarray) # Close enough to former Bunch return
+
+
 def fetch_historical_yahoo(ticker, date1, date2, cachename=None):
 """
 Fetch historical data for ticker between date1 and date2. date1 and
- date2 are datetime instances
+ date2 are date or datetime instances, or (year, month, day) sequences.
 
 Ex:
- fh = fetch_historical_yahoo('^GSPC', d1, d2)
+ fh = fetch_historical_yahoo('^GSPC', (2000, 1, 1), (2001, 12, 31))
 
 cachename is the name of the local file cache. If None, will
 default to the md5 hash or the url (which incorporates the ticker
@@ -106,8 +146,14 @@
 ticker = ticker.upper()
 
 
- d1 = (date1.month-1, date1.day, date1.year)
- d2 = (date2.month-1, date2.day, date2.year)
+ if iterable(date1):
+ d1 = (date1[1]-1, date1[2], date1[0])
+ else:
+ d1 = (date1.month-1, date1.day, date1.year)
+ if iterable(date2):
+ d2 = (date2[1]-1, date2[2], date2[0])
+ else:
+ d2 = (date2.month-1, date2.day, date2.year)
 
 
 urlFmt = 'http://table.finance.yahoo.com/table.csv?a=%d&b=%d&c=%d&d=%d&e=%d&f=%d&s=%s&y=0&g=d&ignore=.csv'
@@ -123,7 +169,8 @@
 fh = file(cachename)
 verbose.report('Using cachefile %s for %s'%(cachename, ticker))
 else:
- if not os.path.isdir(cachedir): os.mkdir(cachedir)
+ if not os.path.isdir(cachedir):
+ os.mkdir(cachedir)
 urlfh = urlopen(url)
 
 fh = file(cachename, 'w')
@@ -135,27 +182,18 @@
 return fh
 
 
-def quotes_historical_yahoo(ticker, date1, date2, asobject=False, adjusted=True, cachename=None):
+def quotes_historical_yahoo(ticker, date1, date2, asobject=False,
+ adjusted=True, cachename=None):
 """
 Get historical data for ticker between date1 and date2. date1 and
- date2 are datetime instances
+ date2 are datetime instances or (year, month, day) sequences.
 
- results are a list of tuples
+ See :func:`parse_yahoo_historical` for explanation of output formats
+ and the *asobject* and *adjusted* kwargs.
 
- (d, open, close, high, low, volume)
-
- where d is a floating poing representation of date, as returned by date2num
-
- if asobject is True, the return val is an object with attrs date,
- open, close, high, low, volume, which are equal length arrays
-
- if adjusted=True, use adjusted prices. Note that volume is not
- adjusted and we are not able to handle volume adjustments properly
- because the Yahoo CSV does not distinguish between split and
- dividend adjustments.
-
 Ex:
- sp = f.quotes_historical_yahoo('^GSPC', d1, d2, asobject=True, adjusted=True)
+ sp = f.quotes_historical_yahoo('^GSPC', d1, d2,
+ asobject=True, adjusted=True)
 returns = (sp.open[1:] - sp.open[:-1])/sp.open[1:]
 [n,bins,patches] = hist(returns, 100)
 mu = mean(returns)
@@ -167,10 +205,18 @@
 default to the md5 hash or the url (which incorporates the ticker
 and date range)
 """
+ # Maybe enable a warning later as part of a slow transition
+ # to using None instead of False.
+ #if asobject is False:
+ # warnings.warn("Recommend changing to asobject=None")
 
 fh = fetch_historical_yahoo(ticker, date1, date2, cachename)
 
- try: ret = parse_yahoo_historical(fh, asobject, adjusted)
+ try:
+ ret = parse_yahoo_historical(fh, asobject=asobject,
+ adjusted=adjusted)
+ if len(ret) == 0:
+ return None
 except IOError, exc:
 warnings.warn('urlopen() failure\n' + url + '\n' + exc.strerror[1])
 return None
@@ -181,7 +227,7 @@
 colorup='k', colordown='r',
 ):
 """
- quotes is a list of (time, open, close, high, low, ...) tuples
+ quotes is a sequence of (time, open, close, high, low, ...) sequences
 
 Represent the time, open, close, high, low as a vertical line
 ranging from low to high. The left tick is the open and the right
@@ -196,9 +242,6 @@
 return value is a list of lines added
 """
 
-
-
-
 lines = []
 for q in quotes:
 
@@ -244,9 +287,9 @@
 
 """
 
- quotes is a list of (time, open, close, high, low, ...) tuples.
- As long as the first 5 elements of the tuples are these values,
- the tuple can be as long as you want (eg it may store volume).
+ quotes is a sequence of (time, open, close, high, low, ...) sequences.
+ As long as the first 5 elements are these values,
+ the record can be as long as you want (eg it may store volume).
 
 time must be in float days format - see date2num
 
@@ -263,12 +306,11 @@
 
 return value is lines, patches where lines is a list of lines
 added and patches is a list of the rectangle patches added
+
 """
 
-
 OFFSET = width/2.0
 
-
 lines = []
 patches = []
 for q in quotes:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8442
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8442&view=rev
Author: efiring
Date: 2010年06月20日 01:34:30 +0000 (2010年6月20日)
Log Message:
-----------
[2564093] backend_wx: don't initialize printer by default; deprecate Printer*
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年06月19日 23:46:47 UTC (rev 8441)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年06月20日 01:34:30 UTC (rev 8442)
@@ -754,7 +754,11 @@
 
 self.macros = {} # dict from wx id to seq of macros
 
- self.Printer_Init()
+ # printer attributes and methods deprecated, 2010年06月19日
+ self._printerData = None
+ self._printerPageData = None
+ self.printer_width = 5.5
+ self.printer_margin = 0.5
 
 def Destroy(self, *args, **kwargs):
 wx.Panel.Destroy(self, *args, **kwargs)
@@ -769,7 +773,12 @@
 wx.TheClipboard.Close()
 
 def Printer_Init(self):
- """initialize printer settings using wx methods"""
+ """
+ initialize printer settings using wx methods
+
+ Deprecated.
+ """
+ warnings.warn("Printer* methods will be removed", DeprecationWarning)
 self.printerData = wx.PrintData()
 self.printerData.SetPaperId(wx.PAPER_LETTER)
 self.printerData.SetPrintMode(wx.PRINT_MODE_PRINTER)
@@ -781,14 +790,37 @@
 self.printer_width = 5.5
 self.printer_margin= 0.5
 
+ def _get_printerData(self):
+ if self._printerData is None:
+ warnings.warn("Printer* methods will be removed", DeprecationWarning)
+ self._printerData = wx.PrintData()
+ self._printerData.SetPaperId(wx.PAPER_LETTER)
+ self._printerData.SetPrintMode(wx.PRINT_MODE_PRINTER)
+ return self._printerData
+ printerData = property(_get_printerData)
+
+ def _get_printerPageData(self):
+ if self._printerPageData is None:
+ warnings.warn("Printer* methods will be removed", DeprecationWarning)
+ self._printerPageData= wx.PageSetupDialogData()
+ self._printerPageData.SetMarginBottomRight((25,25))
+ self._printerPageData.SetMarginTopLeft((25,25))
+ self._printerPageData.SetPrintData(self.printerData)
+ return self._printerPageData
+ printerPageData = property(_get_printerPageData)
+
 def Printer_Setup(self, event=None):
- """set up figure for printing. The standard wx Printer
+ """
+ set up figure for printing. The standard wx Printer
 Setup Dialog seems to die easily. Therefore, this setup
- simply asks for image width and margin for printing. """
+ simply asks for image width and margin for printing.
+ Deprecated.
+ """
 
 dmsg = """Width of output figure in inches.
 The current aspect ratio will be kept."""
 
+ warnings.warn("Printer* methods will be removed", DeprecationWarning)
 dlg = wx.Dialog(self, -1, 'Page Setup for Printing' , (-1,-1))
 df = dlg.GetFont()
 df.SetWeight(wx.NORMAL)
@@ -844,9 +876,14 @@
 return
 
 def Printer_Setup2(self, event=None):
- """set up figure for printing. Using the standard wx Printer
- Setup Dialog. """
+ """
+ set up figure for printing. Using the standard wx Printer
+ Setup Dialog.
 
+ Deprecated.
+ """
+
+ warnings.warn("Printer* methods will be removed", DeprecationWarning)
 if hasattr(self, 'printerData'):
 data = wx.PageSetupDialogData()
 data.SetPrintData(self.printerData)
@@ -865,7 +902,12 @@
 dlg.Destroy()
 
 def Printer_Preview(self, event=None):
- """ generate Print Preview with wx Print mechanism"""
+ """
+ generate Print Preview with wx Print mechanism
+
+ Deprecated.
+ """
+ warnings.warn("Printer* methods will be removed", DeprecationWarning)
 po1 = PrintoutWx(self, width=self.printer_width,
 margin=self.printer_margin)
 po2 = PrintoutWx(self, width=self.printer_width,
@@ -886,7 +928,12 @@
 self.gui_repaint()
 
 def Printer_Print(self, event=None):
- """ Print figure using wx Print mechanism"""
+ """
+ Print figure using wx Print mechanism
+
+ Deprecated.
+ """
+ warnings.warn("Printer* methods will be removed", DeprecationWarning)
 pdd = wx.PrintDialogData()
 # SetPrintData for 2.4 combatibility
 pdd.SetPrintData(self.printerData)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月19日 23:46:53
Revision: 8441
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8441&view=rev
Author: efiring
Date: 2010年06月19日 23:46:47 +0000 (2010年6月19日)
Log Message:
-----------
[1530104, 3017380] slider grabs mouse; patch by C. Gohlke and baxissimo
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backend_bases.py
 trunk/matplotlib/lib/matplotlib/widgets.py
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年06月17日 17:45:38 UTC (rev 8440)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年06月19日 23:46:47 UTC (rev 8441)
@@ -1122,7 +1122,10 @@
 return
 
 # Find all axes containing the mouse
- axes_list = [a for a in self.canvas.figure.get_axes() if a.in_axes(self)]
+ if self.canvas.mouse_grabber is None:
+ axes_list = [a for a in self.canvas.figure.get_axes() if a.in_axes(self)]
+ else:
+ axes_list = [self.canvas.mouse_grabber]
 
 if len(axes_list) == 0: # None found
 self.inaxes = None
@@ -1332,6 +1335,7 @@
 self._lastx, self._lasty = None, None
 self.button_pick_id = self.mpl_connect('button_press_event',self.pick)
 self.scroll_pick_id = self.mpl_connect('scroll_event',self.pick)
+ self.mouse_grabber = None # the axes currently grabbing mouse
 
 if False:
 ## highlight the artists that are hit
@@ -1610,6 +1614,26 @@
 event = IdleEvent(s, self, guiEvent=guiEvent)
 self.callbacks.process(s, event)
 
+ def grab_mouse(self, ax):
+ """
+ Set the child axes which are currently grabbing the mouse events.
+ Usually called by the widgets themselves.
+ It is an error to call this if the mouse is already grabbed by
+ another axes.
+ """
+ if self.mouse_grabber not in (None, ax):
+ raise RuntimeError('two different attempted to grab mouse input')
+ self.mouse_grabber = ax
+
+ def release_mouse(self, ax):
+ """
+ Release the mouse grab held by the axes, ax.
+ Usually called by the widgets.
+ It is ok to call this even if you ax doesn't have the mouse grab currently.
+ """
+ if self.mouse_grabber is ax:
+ self.mouse_grabber = None
+
 def draw(self, *args, **kwargs):
 """
 Render the :class:`~matplotlib.figure.Figure`
Modified: trunk/matplotlib/lib/matplotlib/widgets.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/widgets.py	2010年06月17日 17:45:38 UTC (rev 8440)
+++ trunk/matplotlib/lib/matplotlib/widgets.py	2010年06月19日 23:46:47 UTC (rev 8441)
@@ -106,6 +106,7 @@
 
 
 ax.figure.canvas.mpl_connect('button_press_event', self._click)
+ ax.figure.canvas.mpl_connect('button_release_event', self._release)
 ax.figure.canvas.mpl_connect('motion_notify_event', self._motion)
 ax.set_navigate(False)
 ax.set_axis_bgcolor(color)
@@ -117,8 +118,21 @@
 self._lastcolor = color
 
 def _click(self, event):
- if event.inaxes != self.ax: return
- if not self.eventson: return
+ if event.inaxes != self.ax:
+ return
+ if not self.eventson:
+ return
+ if event.canvas.mouse_grabber != self.ax:
+ event.canvas.grab_mouse(self.ax)
+
+ def _release(self, event):
+ if event.canvas.mouse_grabber != self.ax:
+ return
+ event.canvas.release_mouse(self.ax)
+ if not self.eventson:
+ return
+ if event.inaxes != self.ax: 
+ return
 for cid, func in self.observers.items():
 func(event)
 
@@ -209,6 +223,7 @@
 ax.set_navigate(False)
 
 ax.figure.canvas.mpl_connect('button_press_event', self._update)
+ ax.figure.canvas.mpl_connect('button_release_event', self._update)
 if dragging:
 ax.figure.canvas.mpl_connect('motion_notify_event', self._update)
 self.label = ax.text(-0.02, 0.5, label, transform=ax.transAxes,
@@ -227,14 +242,35 @@
 self.closedmax = closedmax
 self.slidermin = slidermin
 self.slidermax = slidermax
+ self.drag_active = False
 
 def _update(self, event):
 'update the slider position'
- if event.button !=1: return
- if event.inaxes != self.ax: return
+ if event.button != 1:
+ return
+
+ if event.name == 'button_press_event' and event.inaxes == self.ax:
+ self.drag_active = True
+ event.canvas.grab_mouse(self.ax)
+
+ if not self.drag_active: 
+ return
+ 
+ elif ((event.name == 'button_release_event') 
+ or (event.name == 'button_press_event' and event.inaxes != self.ax)):
+ self.drag_active = False
+ event.canvas.release_mouse(self.ax)
+ return
+
 val = event.xdata
- if not self.closedmin and val<=self.valmin: return
- if not self.closedmax and val>=self.valmax: return
+ if val <= self.valmin:
+ if not self.closedmin:
+ return
+ val = self.valmin
+ elif val >= self.valmax:
+ if not self.closedmax:
+ return
+ val = self.valmax
 
 if self.slidermin is not None:
 if val<=self.slidermin.val: return
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8440
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8440&view=rev
Author: jdh2358
Date: 2010年06月17日 17:45:38 +0000 (2010年6月17日)
Log Message:
-----------
add np and plt to default plot namespace in plot directive
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
Modified: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py	2010年06月16日 17:08:43 UTC (rev 8439)
+++ trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py	2010年06月17日 17:45:38 UTC (rev 8440)
@@ -194,7 +194,8 @@
 # it can get at its data files, if any. Add its path to sys.path
 # so it can import any helper modules sitting beside it.
 if plot_code is not None:
- exec(plot_code)
+ exec_code = 'import numpy as np; import matplotlib.pyplot as plt\n%s'%plot_code
+ exec(exec_code)
 else:
 pwd = os.getcwd()
 path, fname = os.path.split(plot_path)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2010年06月16日 17:08:52
Revision: 8439
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8439&view=rev
Author: mdboom
Date: 2010年06月16日 17:08:43 +0000 (2010年6月16日)
Log Message:
-----------
Fix accessing uninitialized memory error.
Modified Paths:
--------------
 trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp	2010年06月15日 19:32:24 UTC (rev 8438)
+++ trunk/matplotlib/src/_image.cpp	2010年06月16日 17:08:43 UTC (rev 8439)
@@ -44,7 +44,7 @@
 Image::Image() :
 bufferIn(NULL), rbufIn(NULL), colsIn(0), rowsIn(0),
 bufferOut(NULL), rbufOut(NULL), colsOut(0), rowsOut(0), BPP(4),
- interpolation(BILINEAR), aspect(ASPECT_FREE), bg(1,1,1,0) {
+ interpolation(BILINEAR), aspect(ASPECT_FREE), bg(1,1,1,0), resample(true) {
 _VERBOSE("Image::Image");
 }
 
@@ -196,7 +196,7 @@
 std::pair<agg::int8u*,bool> bufpair = _get_output_buffer();
 
 Py::Object ret = Py::asObject(Py_BuildValue("lls#", rowsOut, colsOut,
-					 bufpair.first, colsOut*rowsOut*4));
+ bufpair.first, colsOut*rowsOut*4));
 
 if (bufpair.second) delete [] bufpair.first;
 return ret;
@@ -229,7 +229,7 @@
 
 agg::rendering_buffer rtmp;
 rtmp.attach(reinterpret_cast<unsigned char*>(buf), colsOut, rowsOut,
-	 row_len);
+ row_len);
 
 switch (format) {
 case 0:
@@ -259,7 +259,7 @@
 args.verify_length(0);
 int row_len = colsOut * 4;
 PyObject* o = Py_BuildValue("lls#", rowsOut, colsOut,
-			 rbufOut, row_len * rowsOut);
+ rbufOut, row_len * rowsOut);
 return Py::asObject(o);
 }
 
@@ -362,9 +362,9 @@
 typedef agg::span_allocator<agg::rgba8> span_alloc_type;
 span_alloc_type sa;
 agg::rgba8 background(agg::rgba8(int(255*bg.r),
-				 int(255*bg.g),
-				 int(255*bg.b),
-				 int(255*bg.a)));
+ int(255*bg.g),
+ int(255*bg.b),
+ int(255*bg.a)));
 
 // the image path
 agg::path_storage path;
@@ -396,11 +396,11 @@
 
 case NEAREST:
 {
-	typedef agg::span_image_filter_rgba_nn<img_accessor_type, interpolator_type> span_gen_type;
-	typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	span_gen_type sg(ia, interpolator);
-	renderer_type ri(rb, sa, sg);
-	agg::render_scanlines(ras, sl, ri);
+ typedef agg::span_image_filter_rgba_nn<img_accessor_type, interpolator_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
 }
 break;
 
@@ -414,22 +414,22 @@
 case HAMMING: filter.calculate(agg::image_filter_hamming(), norm); break;
 case HERMITE: filter.calculate(agg::image_filter_hermite(), norm); break;
 }
-	if (resample)
-	 {
-	 typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type;
-	 typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	 span_gen_type sg(ia, interpolator, filter);
-	 renderer_type ri(rb, sa, sg);
-	 agg::render_scanlines(ras, sl, ri);
-	 }
-	else
-	 {
-	 typedef agg::span_image_filter_rgba_2x2<img_accessor_type, interpolator_type> span_gen_type;
-	 typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	 span_gen_type sg(ia, interpolator, filter);
-	 renderer_type ri(rb, sa, sg);
-	 agg::render_scanlines(ras, sl, ri);
-	 }
+ if (resample)
+ {
+ typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator, filter);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
+ else
+ {
+ typedef agg::span_image_filter_rgba_2x2<img_accessor_type, interpolator_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator, filter);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
 }
 break;
 case BILINEAR:
@@ -463,22 +463,22 @@
 case LANCZOS: filter.calculate(agg::image_filter_lanczos(radius), norm); break;
 case BLACKMAN: filter.calculate(agg::image_filter_blackman(radius), norm); break;
 }
-	if (resample)
-	 {
-	 typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type;
-	 typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	 span_gen_type sg(ia, interpolator, filter);
-	 renderer_type ri(rb, sa, sg);
-	 agg::render_scanlines(ras, sl, ri);
-	 }
-	else
-	 {
-	 typedef agg::span_image_filter_rgba<img_accessor_type, interpolator_type> span_gen_type;
-	 typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	 span_gen_type sg(ia, interpolator, filter);
-	 renderer_type ri(rb, sa, sg);
-	 agg::render_scanlines(ras, sl, ri);
-	 }
+ if (resample)
+ {
+ typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator, filter);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
+ else
+ {
+ typedef agg::span_image_filter_rgba<img_accessor_type, interpolator_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator, filter);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
 }
 break;
 
@@ -660,7 +660,7 @@
 behaviors().supportSetattr();
 
 add_varargs_method( "apply_rotation", &Image::apply_rotation, Image::apply_rotation__doc__);
- add_varargs_method( "apply_scaling",	&Image::apply_scaling, Image::apply_scaling__doc__);
+ add_varargs_method( "apply_scaling", &Image::apply_scaling, Image::apply_scaling__doc__);
 add_varargs_method( "apply_translation", &Image::apply_translation, Image::apply_translation__doc__);
 add_keyword_method( "as_rgba_str", &Image::as_rgba_str, Image::as_rgba_str__doc__);
 add_varargs_method( "color_conv", &Image::color_conv, Image::color_conv__doc__);
@@ -744,25 +744,25 @@
 size_t ind=0;
 for (size_t j=0; j<thisim->rowsOut; j++) {
 for (size_t i=0; i<thisim->colsOut; i++) {
-	thisx = i+ox;
+ thisx = i+ox;
 
-	if (isflip)
-	 thisy = thisim->rowsOut - j + oy;
-	else
-	 thisy = j+oy;
+ if (isflip)
+ thisy = thisim->rowsOut - j + oy;
+ else
+ thisy = j+oy;
 
 
-	if (thisx>=numcols || thisy>=numrows) {
-	 ind +=4;
-	 continue;
-	}
+ if (thisx>=numcols || thisy>=numrows) {
+ ind +=4;
+ continue;
+ }
 
-	pixfmt::color_type p;
-	p.r = *(thisim->bufferOut+ind++);
-	p.g = *(thisim->bufferOut+ind++);
-	p.b = *(thisim->bufferOut+ind++);
-	p.a = *(thisim->bufferOut+ind++);
-	pixf.blend_pixel(thisx, thisy, p, 255);
+ pixfmt::color_type p;
+ p.r = *(thisim->bufferOut+ind++);
+ p.g = *(thisim->bufferOut+ind++);
+ p.b = *(thisim->bufferOut+ind++);
+ p.a = *(thisim->bufferOut+ind++);
+ pixf.blend_pixel(thisx, thisy, p, 255);
 }
 }
 }
@@ -854,20 +854,20 @@
 
 for (size_t rownum=0; rownum<imo->rowsIn; rownum++) {
 for (size_t colnum=0; colnum<imo->colsIn; colnum++) {
-	offset = rownum*A->strides[0] + colnum*A->strides[1];
-	r = *(double *)(A->data + offset);
-	g = *(double *)(A->data + offset + A->strides[2] );
-	b = *(double *)(A->data + offset + 2*A->strides[2] );
+ offset = rownum*A->strides[0] + colnum*A->strides[1];
+ r = *(double *)(A->data + offset);
+ g = *(double *)(A->data + offset + A->strides[2] );
+ b = *(double *)(A->data + offset + 2*A->strides[2] );
 
-	if (rgba)
-	 alpha = *(double *)(A->data + offset + 3*A->strides[2] );
-	else
-	 alpha = 1.0;
+ if (rgba)
+ alpha = *(double *)(A->data + offset + 3*A->strides[2] );
+ else
+ alpha = 1.0;
 
-	*buffer++ = int(255*r); // red
-	*buffer++ = int(255*g); // green
-	*buffer++ = int(255*b); // blue
-	*buffer++ = int(255*alpha); // alpha
+ *buffer++ = int(255*r); // red
+ *buffer++ = int(255*g); // green
+ *buffer++ = int(255*b); // blue
+ *buffer++ = int(255*alpha); // alpha
 
 }
 }
@@ -963,19 +963,19 @@
 const size_t N = imo->rowsIn * imo->colsIn;
 size_t i = 0;
 while (i<N) {
-	r = *(double *)(A->data++);
-	g = *(double *)(A->data++);
-	b = *(double *)(A->data++);
+ r = *(double *)(A->data++);
+ g = *(double *)(A->data++);
+ b = *(double *)(A->data++);
 
-	if (rgba)
-	 alpha = *(double *)(A->data++);
-	else
-	 alpha = 1.0;
+ if (rgba)
+ alpha = *(double *)(A->data++);
+ else
+ alpha = 1.0;
 
-	*buffer++ = int(255*r); // red
-	*buffer++ = int(255*g); // green
-	*buffer++ = int(255*b); // blue
-	*buffer++ = int(255*alpha); // alpha
+ *buffer++ = int(255*r); // red
+ *buffer++ = int(255*g); // green
+ *buffer++ = int(255*b); // blue
+ *buffer++ = int(255*alpha); // alpha
 
 }
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2010年06月15日 19:32:30
Revision: 8438
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8438&view=rev
Author: mdboom
Date: 2010年06月15日 19:32:24 +0000 (2010年6月15日)
Log Message:
-----------
Fix out-of-buffer read errors.
Modified Paths:
--------------
 trunk/matplotlib/ttconv/pprdrv_tt2.cpp
Modified: trunk/matplotlib/ttconv/pprdrv_tt2.cpp
===================================================================
--- trunk/matplotlib/ttconv/pprdrv_tt2.cpp	2010年06月15日 19:10:19 UTC (rev 8437)
+++ trunk/matplotlib/ttconv/pprdrv_tt2.cpp	2010年06月15日 19:32:24 UTC (rev 8438)
@@ -50,13 +50,13 @@
 int advance_width;
 
 /* Variables to hold the character data. */
- int *epts_ctr;			/* array of contour endpoints */
- int num_pts, num_ctr;		/* number of points, number of coutours */
- FWord *xcoor, *ycoor;		/* arrays of x and y coordinates */
- BYTE *tt_flags;			/* array of TrueType flags */
+ int *epts_ctr; /* array of contour endpoints */
+ int num_pts, num_ctr; /* number of points, number of coutours */
+ FWord *xcoor, *ycoor; /* arrays of x and y coordinates */
+ BYTE *tt_flags; /* array of TrueType flags */
 double *area_ctr;
 char *check_ctr;
- int *ctrset; 		/* in contour index followed by out contour index */
+ int *ctrset; /* in contour index followed by out contour index */
 
 int stack_depth; /* A book-keeping variable for keeping track of the depth of the PS stack */
 
@@ -100,31 +100,31 @@
 */
 void GlyphToType3::stack(TTStreamWriter& stream, int new_elem)
 {
- if( !pdf_mode && num_pts > 25 )			/* Only do something of we will */
-	{				/* have a log of points. */
-	if(stack_depth == 0)
-	 {
- 	 stream.put_char('{');
- 	 stack_depth=1;
- 	 }
+ if( !pdf_mode && num_pts > 25 ) /* Only do something of we will */
+ { /* have a log of points. */
+ if(stack_depth == 0)
+ {
+ stream.put_char('{');
+ stack_depth=1;
+ }
 
-	stack_depth += new_elem;		/* Account for what we propose to add */
+ stack_depth += new_elem; /* Account for what we propose to add */
 
-	if(stack_depth > 100)
- 	 {
- 	 stream.puts("}_e{");
- 	 stack_depth = 3 + new_elem;	/* A rough estimate */
- 	 }
- 	}
+ if(stack_depth > 100)
+ {
+ stream.puts("}_e{");
+ stack_depth = 3 + new_elem; /* A rough estimate */
+ }
+ }
 } /* end of stack() */
 
-void GlyphToType3::stack_end(TTStreamWriter& stream)			/* called at end */
+void GlyphToType3::stack_end(TTStreamWriter& stream) /* called at end */
 {
 if( !pdf_mode && stack_depth )
- 	{
- 	stream.puts("}_e");
- 	stack_depth=0;
- 	}
+ {
+ stream.puts("}_e");
+ stack_depth=0;
+ }
 } /* end of stack_end() */
 
 /*
@@ -163,79 +163,79 @@
 area_ctr[0]=area(xcoor, ycoor, epts_ctr[0]+1);
 
 for (i=1; i<num_ctr; i++)
- 	area_ctr[i]=area(xcoor+epts_ctr[i-1]+1, ycoor+epts_ctr[i-1]+1, epts_ctr[i]-epts_ctr[i-1]);
+ area_ctr[i]=area(xcoor+epts_ctr[i-1]+1, ycoor+epts_ctr[i-1]+1, epts_ctr[i]-epts_ctr[i-1]);
 
 for (i=0; i<num_ctr; i++)
-	{
- 	if (area_ctr[i]>0)
-	 {
-	 ctrset[2*i]=i; ctrset[2*i+1]=nearout(i);
-	 }
-	else
-	 {
-	 ctrset[2*i]=-1; ctrset[2*i+1]=-1;
-	 }
-	}
+ {
+ if (area_ctr[i]>0)
+ {
+ ctrset[2*i]=i; ctrset[2*i+1]=nearout(i);
+ }
+ else
+ {
+ ctrset[2*i]=-1; ctrset[2*i+1]=-1;
+ }
+ }
 
 /* Step thru the coutours. */
 /* I believe that a contour is a detatched */
 /* set of curves and lines. */
 i=j=k=0;
 while( i < num_ctr )
-	{
-	fst = j = (k==0) ? 0 : (epts_ctr[k-1]+1);
+ {
+ fst = j = (k==0) ? 0 : (epts_ctr[k-1]+1);
 
-	/* Move to the first point on the contour. */
-	stack(stream, 3);
-	PSMoveto(stream,xcoor[j],ycoor[j]);
+ /* Move to the first point on the contour. */
+ stack(stream, 3);
+ PSMoveto(stream,xcoor[j],ycoor[j]);
 
-	start_offpt = 0;		/* No off curve points yet. */
+ start_offpt = 0; /* No off curve points yet. */
 
-	/* Step thru the remaining points of this contour. */
-	for(j++; j <= epts_ctr[k]; j++)
-	 {
-	 if (!(tt_flags[j]&1))	/* Off curve */
-		{
-		if (!start_offpt)
-		 { start_offpt = end_offpt = j; }
-		else
-		 end_offpt++;
-		}
-	 else
-		{			/* On Curve */
-		if (start_offpt)
-		 {
-		 stack(stream, 7);
-		 PSCurveto(stream, xcoor[j],ycoor[j],start_offpt,end_offpt);
-		 start_offpt = 0;
-		 }
-		else
-		 {
+ /* Step thru the remaining points of this contour. */
+ for(j++; j <= epts_ctr[k]; j++)
+ {
+ if (!(tt_flags[j]&1)) /* Off curve */
+ {
+ if (!start_offpt)
+ { start_offpt = end_offpt = j; }
+ else
+ end_offpt++;
+ }
+ else
+ { /* On Curve */
+ if (start_offpt)
+ {
+ stack(stream, 7);
+ PSCurveto(stream, xcoor[j],ycoor[j],start_offpt,end_offpt);
+ start_offpt = 0;
+ }
+ else
+ {
 stack(stream, 3);
-		 PSLineto(stream, xcoor[j], ycoor[j]);
-		 }
-		}
-	 }
+ PSLineto(stream, xcoor[j], ycoor[j]);
+ }
+ }
+ }
 
-	/* Do the final curve or line */
-	/* of this coutour. */
-	if (start_offpt)
-	 {
-	 stack(stream, 7); PSCurveto(stream, xcoor[fst],ycoor[fst],start_offpt,end_offpt);
-	 }
-	else
-	 {
-	 stack(stream, 3); PSLineto(stream, xcoor[fst],ycoor[fst]);
-	 }
+ /* Do the final curve or line */
+ /* of this coutour. */
+ if (start_offpt)
+ {
+ stack(stream, 7); PSCurveto(stream, xcoor[fst],ycoor[fst],start_offpt,end_offpt);
+ }
+ else
+ {
+ stack(stream, 3); PSLineto(stream, xcoor[fst],ycoor[fst]);
+ }
 
-	k=nextinctr(i,k);
+ k=nextinctr(i,k);
 
-	if (k==NOMOREINCTR)
-	 i=k=nextoutctr(i);
+ if (k==NOMOREINCTR)
+ i=k=nextoutctr(i);
 
-	 if (i==NOMOREOUTCTR)
-	 break;
-	 }
+ if (i==NOMOREOUTCTR)
+ break;
+ }
 
 /* Now, we can fill the whole thing. */
 stack(stream, 1);
@@ -251,98 +251,104 @@
 } /* end of PSConvert() */
 
 int GlyphToType3::nextoutctr(int co)
-	{
-	int j;
+ {
+ int j;
 
-	for(j=0; j<num_ctr; j++)
-	 if (check_ctr[j]==0 && area_ctr[j] < 0) {
-	 	check_ctr[j]=1;
-	 	return j;
-	 }
+ for(j=0; j<num_ctr; j++)
+ if (check_ctr[j]==0 && area_ctr[j] < 0) {
+ check_ctr[j]=1;
+ return j;
+ }
 
-	return NOMOREOUTCTR;
-	} /* end of nextoutctr() */
+ return NOMOREOUTCTR;
+ } /* end of nextoutctr() */
 
 int GlyphToType3::nextinctr(int co, int ci)
-	{
-	int j;
+ {
+ int j;
 
-	for(j=0; j<num_ctr; j++)
+ for(j=0; j<num_ctr; j++)
 if (ctrset[2*j+1]==co)
 if (check_ctr[ctrset[2*j]]==0) {
-		check_ctr[ctrset[2*j]]=1;
-	 	return ctrset[2*j];
-	 }
+ check_ctr[ctrset[2*j]]=1;
+ return ctrset[2*j];
+ }
 
-	return NOMOREINCTR;
-	}
+ return NOMOREINCTR;
+ }
 
 /*
 ** find the nearest out contour to a specified in contour.
 */
 int GlyphToType3::nearout(int ci)
 {
- int k = 0;			/* !!! is this right? */
+ int k = 0; /* !!! is this right? */
 int co;
 double a, a1=0;
 
 for (co=0; co < num_ctr; co++)
-	{
-	if(area_ctr[co] < 0)
-	 {
-	 a=intest(co,ci);
-	 if (a<0 && a1==0)
-		{
-		k=co;
-		a1=a;
-		}
-	 if(a<0 && a1!=0 && a>a1)
-		{
-		k=co;
-		a1=a;
-		}
-	 }
-	}
+ {
+ if(area_ctr[co] < 0)
+ {
+ a=intest(co,ci);
+ if (a<0 && a1==0)
+ {
+ k=co;
+ a1=a;
+ }
+ if(a<0 && a1!=0 && a>a1)
+ {
+ k=co;
+ a1=a;
+ }
+ }
+ }
 
 return k;
 } /* end of nearout() */
 
 double GlyphToType3::intest(int co, int ci)
-	{
-	int i, j, start, end;
-	double r1, r2, a;
-	FWord xi[3], yi[3];
+ {
+ int i, j, start, end;
+ double r1, r2, a;
+ FWord xi[3], yi[3];
 
-	j=start=(co==0)?0:(epts_ctr[co-1]+1);
-	end=epts_ctr[co];
-	i=(ci==0)?0:(epts_ctr[ci-1]+1);
-	xi[0] = xcoor[i];
-	yi[0] = ycoor[i];
-	r1=sqr(xcoor[start] - xi[0]) + sqr(ycoor[start] - yi[0]);
+ j=start=(co==0)?0:(epts_ctr[co-1]+1);
+ end=epts_ctr[co];
+ i=(ci==0)?0:(epts_ctr[ci-1]+1);
+ xi[0] = xcoor[i];
+ yi[0] = ycoor[i];
+ r1=sqr(xcoor[start] - xi[0]) + sqr(ycoor[start] - yi[0]);
 
-	for (i=start; i<=end; i++) {
-		r2 = sqr(xcoor[i] - xi[0])+sqr(ycoor[i] - yi[0]);
-		if (r2 < r1) {
-			r1=r2; j=i;
-		}
-	}
-	xi[1]=xcoor[j-1]; yi[1]=ycoor[j-1];
-	xi[2]=xcoor[j+1]; yi[2]=ycoor[j+1];
- if (j==start) { xi[1]=xcoor[end]; yi[1]=ycoor[end]; }
-	if (j==end) { xi[2]=xcoor[start]; yi[2]=ycoor[start]; }
-	a=area(xi, yi, 3);
+ for (i=start; i<=end; i++) {
+ r2 = sqr(xcoor[i] - xi[0])+sqr(ycoor[i] - yi[0]);
+ if (r2 < r1) {
+ r1=r2; j=i;
+ }
+ }
+ if (j==start) {
+ xi[1]=xcoor[end]; yi[1]=ycoor[end];
+ } else {
+ xi[1]=xcoor[j-1]; yi[1]=ycoor[j-1];
+ }
+ if (j==end) {
+ xi[2]=xcoor[start]; yi[2]=ycoor[start];
+ } else {
+ xi[2]=xcoor[j+1]; yi[2]=ycoor[j+1];
+ }
+ a=area(xi, yi, 3);
 
-	return a;
-	} /* end of intest() */
+ return a;
+ } /* end of intest() */
 
 void GlyphToType3::PSMoveto(TTStreamWriter& stream, int x, int y) {
 stream.printf(pdf_mode ? "%d %d m\n" : "%d %d _m\n",
-		 x, y);
+ x, y);
 }
 
 void GlyphToType3::PSLineto(TTStreamWriter& stream, int x, int y) {
 stream.printf(pdf_mode ? "%d %d l\n" : "%d %d _l\n",
-		 x, y);
+ x, y);
 }
 
 /*
@@ -355,26 +361,26 @@
 
 N = t-s+2;
 for(i=0; i<N-1; i++)
-	{
-	sx[0] = i==0?xcoor[s-1]:(xcoor[i+s]+xcoor[i+s-1])/2;
-	sy[0] = i==0?ycoor[s-1]:(ycoor[i+s]+ycoor[i+s-1])/2;
-	sx[1] = xcoor[s+i];
-	sy[1] = ycoor[s+i];
-	sx[2] = i==N-2?x:(xcoor[s+i]+xcoor[s+i+1])/2;
-	sy[2] = i==N-2?y:(ycoor[s+i]+ycoor[s+i+1])/2;
-	cx[3] = sx[2];
-	cy[3] = sy[2];
-	cx[1] = (2*sx[1]+sx[0])/3;
-	cy[1] = (2*sy[1]+sy[0])/3;
-	cx[2] = (sx[2]+2*sx[1])/3;
-	cy[2] = (sy[2]+2*sy[1])/3;
+ {
+ sx[0] = i==0?xcoor[s-1]:(xcoor[i+s]+xcoor[i+s-1])/2;
+ sy[0] = i==0?ycoor[s-1]:(ycoor[i+s]+ycoor[i+s-1])/2;
+ sx[1] = xcoor[s+i];
+ sy[1] = ycoor[s+i];
+ sx[2] = i==N-2?x:(xcoor[s+i]+xcoor[s+i+1])/2;
+ sy[2] = i==N-2?y:(ycoor[s+i]+ycoor[s+i+1])/2;
+ cx[3] = sx[2];
+ cy[3] = sy[2];
+ cx[1] = (2*sx[1]+sx[0])/3;
+ cy[1] = (2*sy[1]+sy[0])/3;
+ cx[2] = (sx[2]+2*sx[1])/3;
+ cy[2] = (sy[2]+2*sy[1])/3;
 
-	stream.printf(pdf_mode ?
-		 "%d %d %d %d %d %d c\n" :
-		 "%d %d %d %d %d %d _c\n",
-		 (int)cx[1], (int)cy[1], (int)cx[2], (int)cy[2],
-		 (int)cx[3], (int)cy[3]);
-	}
+ stream.printf(pdf_mode ?
+ "%d %d %d %d %d %d c\n" :
+ "%d %d %d %d %d %d _c\n",
+ (int)cx[1], (int)cy[1], (int)cx[2], (int)cy[2],
+ (int)cx[3], (int)cy[3]);
+ }
 } /* end of PSCurveto() */
 
 /*
@@ -382,10 +388,10 @@
 ** the data for the last simple glyph.
 */
 GlyphToType3::~GlyphToType3() {
- free(tt_flags);		/* The flags array */
- free(xcoor);		/* The X coordinates */
- free(ycoor);		/* The Y coordinates */
- free(epts_ctr);		/* The array of contour endpoints */
+ free(tt_flags); /* The flags array */
+ free(xcoor); /* The X coordinates */
+ free(ycoor); /* The Y coordinates */
+ free(epts_ctr); /* The array of contour endpoints */
 // These last three should be NULL. Just
 // free'ing them for safety.
 free(area_ctr);
@@ -406,10 +412,10 @@
 /* Read the contour endpoints list. */
 epts_ctr = (int *)calloc(num_ctr,sizeof(int));
 for (x = 0; x < num_ctr; x++)
- 	{
- 	epts_ctr[x] = getUSHORT(glyph);
- 	glyph += 2;
- 	}
+ {
+ epts_ctr[x] = getUSHORT(glyph);
+ glyph += 2;
+ }
 
 /* From the endpoint of the last contour, we can */
 /* determine the number of points. */
@@ -432,71 +438,71 @@
 /* Read the flags array, uncompressing it as we go. */
 /* There is danger of overflow here. */
 for (x = 0; x < num_pts; )
-	{
-	tt_flags[x++] = c = *(glyph++);
+ {
+ tt_flags[x++] = c = *(glyph++);
 
-	if (c&8)		/* If next byte is repeat count, */
-	 {
-	 ct = *(glyph++);
+ if (c&8) /* If next byte is repeat count, */
+ {
+ ct = *(glyph++);
 
-	 if( (x + ct) > num_pts )
-		throw TTException("Error in TT flags");
+ if( (x + ct) > num_pts )
+ throw TTException("Error in TT flags");
 
-	 while (ct--)
-		tt_flags[x++] = c;
-	 }
-	}
+ while (ct--)
+ tt_flags[x++] = c;
+ }
+ }
 
 /* Read the x coordinates */
 for (x = 0; x < num_pts; x++)
-	{
-	if (tt_flags[x] & 2)		/* one byte value with */
-	 {				/* external sign */
-	 c = *(glyph++);
-	 xcoor[x] = (tt_flags[x] & 0x10) ? c : (-1 * (int)c);
-	 }
-	else if(tt_flags[x] & 0x10)	/* repeat last */
-	 {
-	 xcoor[x] = 0;
-	 }
-	else				/* two byte signed value */
-	 {
-	 xcoor[x] = getFWord(glyph);
-	 glyph+=2;
-	 }
-	}
+ {
+ if (tt_flags[x] & 2) /* one byte value with */
+ { /* external sign */
+ c = *(glyph++);
+ xcoor[x] = (tt_flags[x] & 0x10) ? c : (-1 * (int)c);
+ }
+ else if(tt_flags[x] & 0x10) /* repeat last */
+ {
+ xcoor[x] = 0;
+ }
+ else /* two byte signed value */
+ {
+ xcoor[x] = getFWord(glyph);
+ glyph+=2;
+ }
+ }
 
 /* Read the y coordinates */
 for(x = 0; x < num_pts; x++)
-	{
-	if (tt_flags[x] & 4)		/* one byte value with */
-	 {				/* external sign */
-	 c = *(glyph++);
-	 ycoor[x] = (tt_flags[x] & 0x20) ? c : (-1 * (int)c);
-	 }
-	else if (tt_flags[x] & 0x20)	/* repeat last value */
-	 {
-	 ycoor[x] = 0;
-	 }
-	else				/* two byte signed value */
-	 {
-	 ycoor[x] = getUSHORT(glyph);
-	 glyph+=2;
-	 }
-	 }
+ {
+ if (tt_flags[x] & 4) /* one byte value with */
+ { /* external sign */
+ c = *(glyph++);
+ ycoor[x] = (tt_flags[x] & 0x20) ? c : (-1 * (int)c);
+ }
+ else if (tt_flags[x] & 0x20) /* repeat last value */
+ {
+ ycoor[x] = 0;
+ }
+ else /* two byte signed value */
+ {
+ ycoor[x] = getUSHORT(glyph);
+ glyph+=2;
+ }
+ }
 
 /* Convert delta values to absolute values. */
 for(x = 1; x < num_pts; x++)
-	{
-	xcoor[x] += xcoor[x-1];
-	ycoor[x] += ycoor[x-1];
-	}
+ {
+ xcoor[x] += xcoor[x-1];
+ ycoor[x] += ycoor[x-1];
+ }
 
 for(x=0; x < num_pts; x++)
-	{
-	xcoor[x] = topost(xcoor[x]);
-	ycoor[x] = topost(ycoor[x]);
-	}
+ {
+ xcoor[x] = topost(xcoor[x]);
+ ycoor[x] = topost(ycoor[x]);
+ }
 
 } /* end of load_char() */
 
@@ -515,101 +521,101 @@
 USHORT scale10;
 
 /* Once around this loop for each component. */
- do	{
-	flags = getUSHORT(glyph);	/* read the flags word */
-	glyph += 2;
+ do {
+ flags = getUSHORT(glyph); /* read the flags word */
+ glyph += 2;
 
-	glyphIndex = getUSHORT(glyph);	/* read the glyphindex word */
-	glyph += 2;
+ glyphIndex = getUSHORT(glyph); /* read the glyphindex word */
+ glyph += 2;
 
-	if(flags & ARG_1_AND_2_ARE_WORDS)
-	 {			/* The tt spec. seems to say these are signed. */
-	 arg1 = getSHORT(glyph);
-	 glyph += 2;
-	 arg2 = getSHORT(glyph);
-	 glyph += 2;
-	 }
- 	else			/* The tt spec. does not clearly indicate */
- 	 {			/* whether these values are signed or not. */
+ if(flags & ARG_1_AND_2_ARE_WORDS)
+ { /* The tt spec. seems to say these are signed. */
+ arg1 = getSHORT(glyph);
+ glyph += 2;
+ arg2 = getSHORT(glyph);
+ glyph += 2;
+ }
+ else /* The tt spec. does not clearly indicate */
+ { /* whether these values are signed or not. */
 arg1 = *(signed char *)(glyph++);
 arg2 = *(signed char *)(glyph++);
-	 }
+ }
 
-	if(flags & WE_HAVE_A_SCALE)
-	 {
-	 xscale = yscale = getUSHORT(glyph);
-	 glyph += 2;
-	 scale01 = scale10 = 0;
-	 }
-	else if(flags & WE_HAVE_AN_X_AND_Y_SCALE)
-	 {
-	 xscale = getUSHORT(glyph);
-	 glyph += 2;
-	 yscale = getUSHORT(glyph);
-	 glyph += 2;
-	 scale01 = scale10 = 0;
-	 }
-	else if(flags & WE_HAVE_A_TWO_BY_TWO)
-	 {
-	 xscale = getUSHORT(glyph);
-	 glyph += 2;
-	 scale01 = getUSHORT(glyph);
-	 glyph += 2;
-	 scale10 = getUSHORT(glyph);
-	 glyph += 2;
-	 yscale = getUSHORT(glyph);
-	 glyph += 2;
-	 }
-	else
-	 {
-	 xscale = yscale = scale01 = scale10 = 0;
-	 }
+ if(flags & WE_HAVE_A_SCALE)
+ {
+ xscale = yscale = getUSHORT(glyph);
+ glyph += 2;
+ scale01 = scale10 = 0;
+ }
+ else if(flags & WE_HAVE_AN_X_AND_Y_SCALE)
+ {
+ xscale = getUSHORT(glyph);
+ glyph += 2;
+ yscale = getUSHORT(glyph);
+ glyph += 2;
+ scale01 = scale10 = 0;
+ }
+ else if(flags & WE_HAVE_A_TWO_BY_TWO)
+ {
+ xscale = getUSHORT(glyph);
+ glyph += 2;
+ scale01 = getUSHORT(glyph);
+ glyph += 2;
+ scale10 = getUSHORT(glyph);
+ glyph += 2;
+ yscale = getUSHORT(glyph);
+ glyph += 2;
+ }
+ else
+ {
+ xscale = yscale = scale01 = scale10 = 0;
+ }
 
-	/* Debugging */
-	#ifdef DEBUG_TRUETYPE
-	stream.printf("%% flags=%d, arg1=%d, arg2=%d, xscale=%d, yscale=%d, scale01=%d, scale10=%d\n",
-		(int)flags,arg1,arg2,(int)xscale,(int)yscale,(int)scale01,(int)scale10);
-	#endif
+ /* Debugging */
+ #ifdef DEBUG_TRUETYPE
+ stream.printf("%% flags=%d, arg1=%d, arg2=%d, xscale=%d, yscale=%d, scale01=%d, scale10=%d\n",
+ (int)flags,arg1,arg2,(int)xscale,(int)yscale,(int)scale01,(int)scale10);
+ #endif
 
-	if (pdf_mode) {
-	 if ( flags & ARGS_ARE_XY_VALUES ) {
-		/* We should have been able to use 'Do' to reference the
-		 subglyph here. However, that doesn't seem to work with
-		 xpdf or gs (only acrobat), so instead, this just includes
-		 the subglyph here inline. */
-		stream.printf("q 1 0 0 1 %d %d cm\n", topost(arg1), topost(arg2));
-	 } else {
-		 stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2);
-	 }
-	 GlyphToType3(stream, font, glyphIndex, true);
-	 if ( flags & ARGS_ARE_XY_VALUES ) {
-		stream.printf("\nQ\n");
-	 }
-	} else {
-	 /* If we have an (X,Y) shif and it is non-zero, */
-	 /* translate the coordinate system. */
-	 if( flags & ARGS_ARE_XY_VALUES )
-		{
-		 if( arg1 != 0 || arg2 != 0 )
-			stream.printf("gsave %d %d translate\n", topost(arg1), topost(arg2) );
-		}
-	 else
-		{
-		 stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2);
-		}
+ if (pdf_mode) {
+ if ( flags & ARGS_ARE_XY_VALUES ) {
+ /* We should have been able to use 'Do' to reference the
+ subglyph here. However, that doesn't seem to work with
+ xpdf or gs (only acrobat), so instead, this just includes
+ the subglyph here inline. */
+ stream.printf("q 1 0 0 1 %d %d cm\n", topost(arg1), topost(arg2));
+ } else {
+ stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2);
+ }
+ GlyphToType3(stream, font, glyphIndex, true);
+ if ( flags & ARGS_ARE_XY_VALUES ) {
+ stream.printf("\nQ\n");
+ }
+ } else {
+ /* If we have an (X,Y) shif and it is non-zero, */
+ /* translate the coordinate system. */
+ if( flags & ARGS_ARE_XY_VALUES )
+ {
+ if( arg1 != 0 || arg2 != 0 )
+ stream.printf("gsave %d %d translate\n", topost(arg1), topost(arg2) );
+ }
+ else
+ {
+ stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2);
+ }
 
-	 /* Invoke the CharStrings procedure to print the component. */
-	 stream.printf("false CharStrings /%s get exec\n",
-			 ttfont_CharStrings_getname(font,glyphIndex));
+ /* Invoke the CharStrings procedure to print the component. */
+ stream.printf("false CharStrings /%s get exec\n",
+ ttfont_CharStrings_getname(font,glyphIndex));
 
-	 /* If we translated the coordinate system, */
-	 /* put it back the way it was. */
-	 if( flags & ARGS_ARE_XY_VALUES && (arg1 != 0 || arg2 != 0) ) {
-		stream.puts("grestore ");
-	 }
-	}
+ /* If we translated the coordinate system, */
+ /* put it back the way it was. */
+ if( flags & ARGS_ARE_XY_VALUES && (arg1 != 0 || arg2 != 0) ) {
+ stream.puts("grestore ");
+ }
+ }
 
-	} while(flags & MORE_COMPONENTS);
+ } while(flags & MORE_COMPONENTS);
 
 } /* end of do_composite() */
 
@@ -623,24 +629,24 @@
 
 /* Read the glyph offset from the index to location table. */
 if(font->indexToLocFormat == 0)
-	{
-	off = getUSHORT( font->loca_table + (charindex * 2) );
-	off *= 2;
-	length = getUSHORT( font->loca_table + ((charindex+1) * 2) );
-	length *= 2;
-	length -= off;
-	}
+ {
+ off = getUSHORT( font->loca_table + (charindex * 2) );
+ off *= 2;
+ length = getUSHORT( font->loca_table + ((charindex+1) * 2) );
+ length *= 2;
+ length -= off;
+ }
 else
-	{
-	off = getULONG( font->loca_table + (charindex * 4) );
-	length = getULONG( font->loca_table + ((charindex+1) * 4) );
-	length -= off;
-	}
+ {
+ off = getULONG( font->loca_table + (charindex * 4) );
+ length = getULONG( font->loca_table + ((charindex+1) * 4) );
+ length -= off;
+ }
 
 if(length > 0)
- 	return font->glyf_table + off;
+ return font->glyf_table + off;
 else
- 	return (BYTE*)NULL;
+ return (BYTE*)NULL;
 
 } /* end of find_glyph_data() */
 
@@ -663,61 +669,61 @@
 /* If the character is blank, it has no bounding box, */
 /* otherwise read the bounding box. */
 if( glyph == (BYTE*)NULL )
- 	{
-	llx=lly=urx=ury=0;	/* A blank char has an all zero BoundingBox */
-	num_ctr=0;		/* Set this for later if()s */
- 	}
+ {
+ llx=lly=urx=ury=0; /* A blank char has an all zero BoundingBox */
+ num_ctr=0; /* Set this for later if()s */
+ }
 else
-	{
-	/* Read the number of contours. */
-	num_ctr = getSHORT(glyph);
+ {
+ /* Read the number of contours. */
+ num_ctr = getSHORT(glyph);
 
-	/* Read PostScript bounding box. */
-	llx = getFWord(glyph + 2);
-	lly = getFWord(glyph + 4);
-	urx = getFWord(glyph + 6);
-	ury = getFWord(glyph + 8);
+ /* Read PostScript bounding box. */
+ llx = getFWord(glyph + 2);
+ lly = getFWord(glyph + 4);
+ urx = getFWord(glyph + 6);
+ ury = getFWord(glyph + 8);
 
-	/* Advance the pointer. */
-	glyph += 10;
-	}
+ /* Advance the pointer. */
+ glyph += 10;
+ }
 
 /* If it is a simple character, load its data. */
 if (num_ctr > 0)
-	load_char(font, glyph);
+ load_char(font, glyph);
 else
 num_pts=0;
 
 /* Consult the horizontal metrics table to determine */
 /* the character width. */
 if( charindex < font->numberOfHMetrics )
-	advance_width = getuFWord( font->hmtx_table + (charindex * 4) );
+ advance_width = getuFWord( font->hmtx_table + (charindex * 4) );
 else
- 	advance_width = getuFWord( font->hmtx_table + ((font->numberOfHMetrics-1) * 4) );
+ advance_width = getuFWord( font->hmtx_table + ((font->numberOfHMetrics-1) * 4) );
 
 /* Execute setcachedevice in order to inform the font machinery */
 /* of the character bounding box and advance width. */
 stack(stream, 7);
 if (pdf_mode) {
-	if (!embedded)
-	 stream.printf("%d 0 %d %d %d %d d1\n",
-			 topost(advance_width),
-			 topost(llx), topost(lly), topost(urx), topost(ury) );
+ if (!embedded)
+ stream.printf("%d 0 %d %d %d %d d1\n",
+ topost(advance_width),
+ topost(llx), topost(lly), topost(urx), topost(ury) );
 } else
-	stream.printf("%d 0 %d %d %d %d _sc\n",
-		 topost(advance_width),
-		 topost(llx), topost(lly), topost(urx), topost(ury) );
+ stream.printf("%d 0 %d %d %d %d _sc\n",
+ topost(advance_width),
+ topost(llx), topost(lly), topost(urx), topost(ury) );
 
 /* If it is a simple glyph, convert it, */
 /* otherwise, close the stack business. */
- if( num_ctr > 0 )		/* simple */
-	{
+ if( num_ctr > 0 ) /* simple */
+ {
 PSConvert(stream);
-	}
- else if( num_ctr < 0 )	/* composite */
-	{
-	 do_composite(stream, font, glyph);
-	}
+ }
+ else if( num_ctr < 0 ) /* composite */
+ {
+ do_composite(stream, font, glyph);
+ }
 
 stack_end(stream);
 }
@@ -740,50 +746,50 @@
 
 std::stack<int> glyph_stack;
 for (std::vector<int>::iterator i = glyph_ids.begin();
-	 i != glyph_ids.end(); ++i) {
-	glyph_stack.push(*i);
+ i != glyph_ids.end(); ++i) {
+ glyph_stack.push(*i);
 }
 
 while (glyph_stack.size()) {
-	int gind = glyph_stack.top();
-	glyph_stack.pop();
+ int gind = glyph_stack.top();
+ glyph_stack.pop();
 
-	BYTE* glyph = find_glyph_data( font, gind );
-	if (glyph != (BYTE*)NULL) {
+ BYTE* glyph = find_glyph_data( font, gind );
+ if (glyph != (BYTE*)NULL) {
 
-	 int num_ctr = getSHORT(glyph);
-	 if (num_ctr <= 0) { // This is a composite glyph
+ int num_ctr = getSHORT(glyph);
+ if (num_ctr <= 0) { // This is a composite glyph
 
-		glyph += 10;
-		USHORT flags = 0;
+ glyph += 10;
+ USHORT flags = 0;
 
-		do {
-		 flags = getUSHORT(glyph);
-		 glyph += 2;
-		 gind = (int)getUSHORT(glyph);
-		 glyph += 2;
+ do {
+ flags = getUSHORT(glyph);
+ glyph += 2;
+ gind = (int)getUSHORT(glyph);
+ glyph += 2;
 
-		 std::vector<int>::iterator insertion =
-			std::lower_bound(glyph_ids.begin(), glyph_ids.end(), gind);
-		 if (*insertion != gind) {
-			glyph_ids.insert(insertion, gind);
-			glyph_stack.push(gind);
-		 }
+ std::vector<int>::iterator insertion =
+ std::lower_bound(glyph_ids.begin(), glyph_ids.end(), gind);
+ if (*insertion != gind) {
+ glyph_ids.insert(insertion, gind);
+ glyph_stack.push(gind);
+ }
 
-		 if (flags & ARG_1_AND_2_ARE_WORDS)
-			glyph += 4;
-		 else
-			glyph += 2;
+ if (flags & ARG_1_AND_2_ARE_WORDS)
+ glyph += 4;
+ else
+ glyph += 2;
 
-		 if (flags & WE_HAVE_A_SCALE)
-			glyph += 2;
-		 else if (flags & WE_HAVE_AN_X_AND_Y_SCALE)
-			glyph += 4;
-		 else if (flags & WE_HAVE_A_TWO_BY_TWO)
-			glyph += 8;
-		} while (flags & MORE_COMPONENTS);
-	 }
-	}
+ if (flags & WE_HAVE_A_SCALE)
+ glyph += 2;
+ else if (flags & WE_HAVE_AN_X_AND_Y_SCALE)
+ glyph += 4;
+ else if (flags & WE_HAVE_A_TWO_BY_TWO)
+ glyph += 8;
+ } while (flags & MORE_COMPONENTS);
+ }
+ }
 }
 }
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2010年06月15日 19:10:26
Revision: 8437
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8437&view=rev
Author: mdboom
Date: 2010年06月15日 19:10:19 +0000 (2010年6月15日)
Log Message:
-----------
Use the word "snapping" everywhere for consistency. This is the word used in the outward-facing interface all along.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/path.py
 trunk/matplotlib/src/_backend_agg.cpp
 trunk/matplotlib/src/_backend_agg.h
 trunk/matplotlib/src/_macosx.m
 trunk/matplotlib/src/_path.cpp
 trunk/matplotlib/src/path_cleanup.cpp
 trunk/matplotlib/src/path_cleanup.h
 trunk/matplotlib/src/path_converters.h
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py	2010年06月15日 13:01:22 UTC (rev 8436)
+++ trunk/matplotlib/lib/matplotlib/path.py	2010年06月15日 19:10:19 UTC (rev 8437)
@@ -188,7 +188,7 @@
 return len(self.vertices)
 
 def iter_segments(self, transform=None, remove_nans=True, clip=None,
- quantize=False, stroke_width=1.0, simplify=None,
+ snap=False, stroke_width=1.0, simplify=None,
 curves=True):
 """
 Iterates over all of the curve segments in the path. Each
@@ -208,11 +208,12 @@
 *clip*: if not None, must be a four-tuple (x1, y1, x2, y2)
 defining a rectangle in which to clip the path.
 
- *quantize*: if None, auto-quantize. If True, force quantize,
- and if False, don't quantize.
+ *snap*: if None, auto-snap to pixels, to reduce
+ fuzziness of rectilinear lines. If True, force snapping, and
+ if False, don't snap.
 
 *stroke_width*: the width of the stroke being drawn. Needed
- as a hint for the quantizer.
+ as a hint for the snapping algorithm.
 
 *simplify*: if True, perform simplification, to remove
 vertices that do not affect the appearance of the path. If
@@ -236,7 +237,7 @@
 STOP = self.STOP
 
 vertices, codes = cleanup_path(self, transform, remove_nans, clip,
- quantize, stroke_width, simplify, curves)
+ snap, stroke_width, simplify, curves)
 len_vertices = len(vertices)
 
 i = 0
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2010年06月15日 13:01:22 UTC (rev 8436)
+++ trunk/matplotlib/src/_backend_agg.cpp	2010年06月15日 19:10:19 UTC (rev 8437)
@@ -270,11 +270,11 @@
 Py::Callable method(method_obj);
 Py::Object py_snap = method.apply(Py::Tuple());
 if (py_snap.isNone()) {
- quantize_mode = QUANTIZE_AUTO;
+ snap_mode = SNAP_AUTO;
 } else if (py_snap.isTrue()) {
- quantize_mode = QUANTIZE_TRUE;
+ snap_mode = SNAP_TRUE;
 } else {
- quantize_mode = QUANTIZE_FALSE;
+ snap_mode = SNAP_FALSE;
 }
 }
 
@@ -506,8 +506,8 @@
 Py::Object
 RendererAgg::draw_markers(const Py::Tuple& args) {
 typedef agg::conv_transform<PathIterator> transformed_path_t;
- typedef PathQuantizer<transformed_path_t> quantize_t;
- typedef agg::conv_curve<quantize_t> curve_t;
+ typedef PathSnapper<transformed_path_t> snap_t;
+ typedef agg::conv_curve<snap_t> curve_t;
 typedef agg::conv_stroke<curve_t> stroke_t;
 typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type;
 typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type;
@@ -533,19 +533,19 @@
 
 PathIterator marker_path(marker_path_obj);
 transformed_path_t marker_path_transformed(marker_path, marker_trans);
- quantize_t marker_path_quantized(marker_path_transformed,
- gc.quantize_mode,
- marker_path.total_vertices(),
- gc.linewidth);
- curve_t marker_path_curve(marker_path_quantized);
+ snap_t marker_path_snapped(marker_path_transformed,
+ gc.snap_mode,
+ marker_path.total_vertices(),
+ gc.linewidth);
+ curve_t marker_path_curve(marker_path_snapped);
 
 PathIterator path(path_obj);
 transformed_path_t path_transformed(path, trans);
- quantize_t path_quantized(path_transformed,
- gc.quantize_mode,
- path.total_vertices(),
- 1.0);
- curve_t path_curve(path_quantized);
+ snap_t path_snapped(path_transformed,
+ gc.snap_mode,
+ path.total_vertices(),
+ 1.0);
+ curve_t path_curve(path_snapped);
 path_curve.rewind(0);
 
 facepair_t face = _get_rgba_face(face_obj, gc.alpha);
@@ -1079,8 +1079,8 @@
 typedef agg::conv_transform<PathIterator> transformed_path_t;
 typedef PathNanRemover<transformed_path_t> nan_removed_t;
 typedef PathClipper<nan_removed_t> clipped_t;
- typedef PathQuantizer<clipped_t> quantized_t;
- typedef PathSimplifier<quantized_t> simplify_t;
+ typedef PathSnapper<clipped_t> snapped_t;
+ typedef PathSimplifier<snapped_t> simplify_t;
 typedef agg::conv_curve<simplify_t> curve_t;
 
 _VERBOSE("RendererAgg::draw_path");
@@ -1108,8 +1108,8 @@
 transformed_path_t tpath(path, trans);
 nan_removed_t nan_removed(tpath, true, path.has_curves());
 clipped_t clipped(nan_removed, clip, width, height);
- quantized_t quantized(clipped, gc.quantize_mode, path.total_vertices(), gc.linewidth);
- simplify_t simplified(quantized, simplify, path.simplify_threshold());
+ snapped_t snapped(clipped, gc.snap_mode, path.total_vertices(), gc.linewidth);
+ simplify_t simplified(snapped, simplify, path.simplify_threshold());
 curve_t curve(simplified);
 
 try {
@@ -1141,8 +1141,8 @@
 typedef agg::conv_transform<typename PathGenerator::path_iterator> transformed_path_t;
 typedef PathNanRemover<transformed_path_t> nan_removed_t;
 typedef PathClipper<nan_removed_t> clipped_t;
- typedef PathQuantizer<clipped_t> quantized_t;
- typedef agg::conv_curve<quantized_t> quantized_curve_t;
+ typedef PathSnapper<clipped_t> snapped_t;
+ typedef agg::conv_curve<snapped_t> snapped_curve_t;
 typedef agg::conv_curve<clipped_t> curve_t;
 
 PyArrayObject* offsets = NULL;
@@ -1275,13 +1275,13 @@
 transformed_path_t tpath(path, trans);
 nan_removed_t nan_removed(tpath, true, has_curves);
 clipped_t clipped(nan_removed, do_clip, width, height);
- quantized_t quantized(clipped, gc.quantize_mode,
- path.total_vertices(), gc.linewidth);
+ snapped_t snapped(clipped, gc.snap_mode,
+ path.total_vertices(), gc.linewidth);
 if (has_curves) {
- quantized_curve_t curve(quantized);
+ snapped_curve_t curve(snapped);
 _draw_path(curve, has_clippath, face, gc);
 } else {
- _draw_path(quantized, has_clippath, face, gc);
+ _draw_path(snapped, has_clippath, face, gc);
 }
 } else {
 gc.isaa = bool(Py::Int(antialiaseds[i % Naa]));
Modified: trunk/matplotlib/src/_backend_agg.h
===================================================================
--- trunk/matplotlib/src/_backend_agg.h	2010年06月15日 13:01:22 UTC (rev 8436)
+++ trunk/matplotlib/src/_backend_agg.h	2010年06月15日 19:10:19 UTC (rev 8437)
@@ -123,7 +123,7 @@
 typedef std::vector<std::pair<double, double> > dash_t;
 double dashOffset;
 dash_t dashes;
- e_quantize_mode quantize_mode;
+ e_snap_mode snap_mode;
 
 Py::Object hatchpath;
 
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m	2010年06月15日 13:01:22 UTC (rev 8436)
+++ trunk/matplotlib/src/_macosx.m	2010年06月15日 19:10:19 UTC (rev 8437)
@@ -288,7 +288,7 @@
 0,
 0,
 rect,
- QUANTIZE_FALSE,
+ SNAP_FALSE,
 1.0,
 0);
 Py_DECREF(transform);
@@ -446,13 +446,13 @@
 return p;
 }
 
-static int _get_snap(GraphicsContext* self, enum e_quantize_mode* mode)
+static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode)
 {
 PyObject* snap = PyObject_CallMethod((PyObject*)self, "get_snap", "");
 if(!snap) return 0;
- if(snap==Py_None) *mode = QUANTIZE_AUTO;
- else if (PyBool_Check(snap)) *mode = QUANTIZE_TRUE;
- else *mode = QUANTIZE_FALSE;
+ if(snap==Py_None) *mode = SNAP_AUTO;
+ else if (PyBool_Check(snap)) *mode = SNAP_TRUE;
+ else *mode = SNAP_FALSE;
 Py_DECREF(snap);
 return 1;
 }
@@ -662,7 +662,7 @@
 0,
 0,
 rect,
- QUANTIZE_AUTO,
+ SNAP_AUTO,
 1.0,
 0);
 Py_DECREF(transform);
@@ -892,7 +892,7 @@
 1,
 0,
 rect,
- QUANTIZE_AUTO,
+ SNAP_AUTO,
 linewidth,
 rgbFace == NULL);
 if (!iterator)
@@ -970,7 +970,7 @@
 1,
 0,
 rect,
- QUANTIZE_AUTO,
+ SNAP_AUTO,
 linewidth,
 0);
 if (!iterator)
@@ -1006,7 +1006,7 @@
 CGMutablePathRef marker;
 void* iterator;
 double rect[4] = {0.0, 0.0, self->size.width, self->size.height};
- enum e_quantize_mode mode;
+ enum e_snap_mode mode;
 double xc, yc;
 unsigned code;
 
@@ -1071,7 +1071,7 @@
 1,
 1,
 rect,
- QUANTIZE_TRUE,
+ SNAP_TRUE,
 1.0,
 0);
 if (!iterator)
@@ -1225,7 +1225,7 @@
 /* --------- Prepare some variables for the path iterator ------------- */
 void* iterator;
 double rect[4] = {0.0, 0.0, self->size.width, self->size.height};
- enum e_quantize_mode mode;
+ enum e_snap_mode mode;
 ok = _get_snap(self, &mode);
 if (!ok)
 {
@@ -1382,7 +1382,7 @@
 0,
 0,
 rect,
- QUANTIZE_AUTO,
+ SNAP_AUTO,
 1.0,
 0);
 if (!iterator)
@@ -1690,7 +1690,7 @@
 0,
 0,
 rect,
- QUANTIZE_AUTO,
+ SNAP_AUTO,
 1.0,
 0);
 if (iterator)
@@ -2676,7 +2676,7 @@
 0,
 0,
 rect,
- QUANTIZE_AUTO,
+ SNAP_AUTO,
 1.0,
 0);
 if (iterator)
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp	2010年06月15日 13:01:22 UTC (rev 8436)
+++ trunk/matplotlib/src/_path.cpp	2010年06月15日 19:10:19 UTC (rev 8437)
@@ -55,7 +55,7 @@
 add_varargs_method("convert_path_to_polygons", &_path_module::convert_path_to_polygons,
 "convert_path_to_polygons(path, trans, width, height)");
 add_varargs_method("cleanup_path", &_path_module::cleanup_path,
- "cleanup_path(path, trans, remove_nans, clip, quantize, simplify, curves)");
+ "cleanup_path(path, trans, remove_nans, clip, snap, simplify, curves)");
 initialize("Helper functions for paths");
 }
 
@@ -1228,22 +1228,22 @@
 void _cleanup_path(PathIterator& path, const agg::trans_affine& trans,
 bool remove_nans, bool do_clip,
 const agg::rect_base<double>& rect,
- e_quantize_mode quantize_mode, double stroke_width,
+ e_snap_mode snap_mode, double stroke_width,
 bool do_simplify, bool return_curves,
 std::vector<double>& vertices,
 std::vector<npy_uint8>& codes) {
 typedef agg::conv_transform<PathIterator> transformed_path_t;
 typedef PathNanRemover<transformed_path_t> nan_removal_t;
 typedef PathClipper<nan_removal_t> clipped_t;
- typedef PathQuantizer<clipped_t> quantized_t;
- typedef PathSimplifier<quantized_t> simplify_t;
+ typedef PathSnapper<clipped_t> snapped_t;
+ typedef PathSimplifier<snapped_t> simplify_t;
 typedef agg::conv_curve<simplify_t> curve_t;
 
 transformed_path_t tpath(path, trans);
 nan_removal_t nan_removed(tpath, remove_nans, path.has_curves());
 clipped_t clipped(nan_removed, do_clip, rect);
- quantized_t quantized(clipped, quantize_mode, path.total_vertices(), stroke_width);
- simplify_t simplified(quantized, do_simplify, path.simplify_threshold());
+ snapped_t snapped(clipped, snap_mode, path.total_vertices(), stroke_width);
+ simplify_t simplified(snapped, do_simplify, path.simplify_threshold());
 
 vertices.reserve(path.total_vertices() * 2);
 codes.reserve(path.total_vertices());
@@ -1286,19 +1286,19 @@
 do_clip = true;
 }
 
- Py::Object quantize_obj = args[4];
- e_quantize_mode quantize_mode;
- if (quantize_obj.isNone())
+ Py::Object snap_obj = args[4];
+ e_snap_mode snap_mode;
+ if (snap_obj.isNone())
 {
- quantize_mode = QUANTIZE_AUTO;
+ snap_mode = SNAP_AUTO;
 }
- else if (quantize_obj.isTrue())
+ else if (snap_obj.isTrue())
 {
- quantize_mode = QUANTIZE_TRUE;
+ snap_mode = SNAP_TRUE;
 }
 else
 {
- quantize_mode = QUANTIZE_FALSE;
+ snap_mode = SNAP_FALSE;
 }
 
 double stroke_width = Py::Float(args[5]);
@@ -1319,7 +1319,7 @@
 std::vector<double> vertices;
 std::vector<npy_uint8> codes;
 
- _cleanup_path(path, trans, remove_nans, do_clip, clip_rect, quantize_mode,
+ _cleanup_path(path, trans, remove_nans, do_clip, clip_rect, snap_mode,
 stroke_width, simplify, return_curves, vertices, codes);
 
 npy_intp length = codes.size();
Modified: trunk/matplotlib/src/path_cleanup.cpp
===================================================================
--- trunk/matplotlib/src/path_cleanup.cpp	2010年06月15日 13:01:22 UTC (rev 8436)
+++ trunk/matplotlib/src/path_cleanup.cpp	2010年06月15日 19:10:19 UTC (rev 8437)
@@ -12,8 +12,8 @@
 typedef agg::conv_transform<PathIterator> transformed_path_t;
 typedef PathNanRemover<transformed_path_t> nan_removal_t;
 typedef PathClipper<nan_removal_t> clipped_t;
- typedef PathQuantizer<clipped_t> quantized_t;
- typedef PathSimplifier<quantized_t> simplify_t;
+ typedef PathSnapper<clipped_t> snapped_t;
+ typedef PathSimplifier<snapped_t> simplify_t;
 
 Py::Object m_path_obj;
 PathIterator m_path_iter;
@@ -21,14 +21,14 @@
 transformed_path_t m_transformed;
 nan_removal_t m_nan_removed;
 clipped_t m_clipped;
- quantized_t m_quantized;
+ snapped_t m_snapped;
 simplify_t m_simplify;
 
 public:
 PathCleanupIterator(PyObject* path, agg::trans_affine trans,
 bool remove_nans, bool do_clip,
 const agg::rect_base<double>& rect,
- e_quantize_mode quantize_mode, double stroke_width,
+ e_snap_mode snap_mode, double stroke_width,
 bool do_simplify) :
 m_path_obj(path, true),
 m_path_iter(m_path_obj),
@@ -36,9 +36,9 @@
 m_transformed(m_path_iter, m_transform),
 m_nan_removed(m_transformed, remove_nans, m_path_iter.has_curves()),
 m_clipped(m_nan_removed, do_clip, rect),
- m_quantized(m_clipped, quantize_mode, m_path_iter.total_vertices(),
- stroke_width),
- m_simplify(m_quantized, do_simplify && m_path_iter.should_simplify(),
+ m_snapped(m_clipped, snap_mode, m_path_iter.total_vertices(),
+ stroke_width),
+ m_simplify(m_snapped, do_simplify && m_path_iter.should_simplify(),
 m_path_iter.simplify_threshold())
 {
 Py_INCREF(path);
@@ -55,7 +55,7 @@
 void*
 get_path_iterator(
 PyObject* path, PyObject* trans, int remove_nans, int do_clip,
- double rect[4], e_quantize_mode quantize_mode, double stroke_width,
+ double rect[4], e_snap_mode snap_mode, double stroke_width,
 int do_simplify)
 {
 agg::trans_affine agg_trans = py_to_agg_transformation_matrix(trans, false);
@@ -63,7 +63,7 @@
 
 PathCleanupIterator* pipeline = new PathCleanupIterator(
 path, agg_trans, remove_nans != 0, do_clip != 0,
- clip_rect, quantize_mode, stroke_width, do_simplify != 0);
+ clip_rect, snap_mode, stroke_width, do_simplify != 0);
 
 return (void*)pipeline;
 }
Modified: trunk/matplotlib/src/path_cleanup.h
===================================================================
--- trunk/matplotlib/src/path_cleanup.h	2010年06月15日 13:01:22 UTC (rev 8436)
+++ trunk/matplotlib/src/path_cleanup.h	2010年06月15日 19:10:19 UTC (rev 8437)
@@ -3,17 +3,17 @@
 
 #include <Python.h>
 
-enum e_quantize_mode
+enum e_snap_mode
 {
- QUANTIZE_AUTO,
- QUANTIZE_FALSE,
- QUANTIZE_TRUE
+ SNAP_AUTO,
+ SNAP_FALSE,
+ SNAP_TRUE
 };
 
 void*
 get_path_iterator(
 PyObject* path, PyObject* trans, int remove_nans, int do_clip,
- double rect[4], enum e_quantize_mode quantize_mode, double stroke_width,
+ double rect[4], enum e_snap_mode snap_mode, double stroke_width,
 int do_simplify);
 
 unsigned
Modified: trunk/matplotlib/src/path_converters.h
===================================================================
--- trunk/matplotlib/src/path_converters.h	2010年06月15日 13:01:22 UTC (rev 8436)
+++ trunk/matplotlib/src/path_converters.h	2010年06月15日 19:10:19 UTC (rev 8437)
@@ -26,7 +26,7 @@
 Agg where coordinates can not be larger than 24-bit signed
 integers.
 
- 4. PathQuantizer: Rounds the path to the nearest center-pixels.
+ 4. PathSnapper: Rounds the path to the nearest center-pixels.
 This makes rectilinear curves look much better.
 
 5. PathSimplifier: Removes line segments from highly dense paths
@@ -361,36 +361,36 @@
 };
 
 /************************************************************
- PathQuantizer rounds vertices to their nearest center-pixels. This
+ PathSnapper rounds vertices to their nearest center-pixels. This
 makes rectilinear paths (rectangles, horizontal and vertical lines
 etc.) look much cleaner.
 */
-enum e_quantize_mode
+enum e_snap_mode
 {
- QUANTIZE_AUTO,
- QUANTIZE_FALSE,
- QUANTIZE_TRUE
+ SNAP_AUTO,
+ SNAP_FALSE,
+ SNAP_TRUE
 };
 
 template<class VertexSource>
-class PathQuantizer
+class PathSnapper
 {
 private:
 VertexSource* m_source;
- bool m_quantize;
- double m_quantize_value;
+ bool m_snap;
+ double m_snap_value;
 
- static bool should_quantize(VertexSource& path,
- e_quantize_mode quantize_mode,
- unsigned total_vertices) {
+ static bool should_snap(VertexSource& path,
+ e_snap_mode snap_mode,
+ unsigned total_vertices) {
 // If this contains only straight horizontal or vertical lines, it should be
- // quantized to the nearest pixels
+ // snapped to the nearest pixels
 double x0, y0, x1, y1;
 unsigned code;
 
- switch (quantize_mode)
+ switch (snap_mode)
 {
- case QUANTIZE_AUTO:
+ case SNAP_AUTO:
 if (total_vertices > 1024)
 {
 return false;
@@ -420,9 +420,9 @@
 }
 
 return true;
- case QUANTIZE_FALSE:
+ case SNAP_FALSE:
 return false;
- case QUANTIZE_TRUE:
+ case SNAP_TRUE:
 return true;
 }
 
@@ -431,21 +431,21 @@
 
 public:
 /*
- quantize_mode should be one of:
- - QUANTIZE_AUTO: Examine the path to determine if it should be quantized
- - QUANTIZE_TRUE: Force quantization
- - QUANTIZE_FALSE: No quantization
+ snap_mode should be one of:
+ - SNAP_AUTO: Examine the path to determine if it should be snapped
+ - SNAP_TRUE: Force snapping
+ - SNAP_FALSE: No snapping
 */
- PathQuantizer(VertexSource& source, e_quantize_mode quantize_mode,
+ PathSnapper(VertexSource& source, e_snap_mode snap_mode,
 unsigned total_vertices=15, double stroke_width=0.0) :
 m_source(&source)
 {
- m_quantize = should_quantize(source, quantize_mode, total_vertices);
+ m_snap = should_snap(source, snap_mode, total_vertices);
 
- if (m_quantize)
+ if (m_snap)
 {
- int odd_even = (int)mpl_round(stroke_width) % 2;
- m_quantize_value = (odd_even) ? 0.5 : 0.0;
+ int is_odd = (int)mpl_round(stroke_width) % 2;
+ m_snap_value = (is_odd) ? 0.5 : 0.0;
 }
 
 source.rewind(0);
@@ -460,17 +460,17 @@
 {
 unsigned code;
 code = m_source->vertex(x, y);
- if (m_quantize && agg::is_vertex(code))
- {
- *x = mpl_round(*x) + m_quantize_value;
- *y = mpl_round(*y) + m_quantize_value;
+ if (m_snap && agg::is_vertex(code))
+ {
+ *x = mpl_round(*x) + m_snap_value;
+ *y = mpl_round(*y) + m_snap_value;
 }
 return code;
 }
 
- inline bool is_quantizing()
+ inline bool is_snapping()
 {
- return m_quantize;
+ return m_snap;
 }
 };
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8436
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8436&view=rev
Author: mdboom
Date: 2010年06月15日 13:01:22 +0000 (2010年6月15日)
Log Message:
-----------
Support the "Enter" key event in the Qt4 backend.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py	2010年06月14日 05:51:06 UTC (rev 8435)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py	2010年06月15日 13:01:22 UTC (rev 8436)
@@ -129,6 +129,7 @@
 keyvald = { QtCore.Qt.Key_Control : 'control',
 QtCore.Qt.Key_Shift : 'shift',
 QtCore.Qt.Key_Alt : 'alt',
+ QtCore.Qt.Key_Return : 'enter'
 }
 # left 1, middle 2, right 3
 buttond = {1:1, 2:3, 4:2}
@@ -314,16 +315,19 @@
 self.window._destroying = False
 
 self.toolbar = self._get_toolbar(self.canvas, self.window)
- self.window.addToolBar(self.toolbar)
- QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"),
- self.window.statusBar().showMessage)
+ if self.toolbar is not None:
+ self.window.addToolBar(self.toolbar)
+ QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"),
+ self.window.statusBar().showMessage)
+ tbs_height = self.toolbar.sizeHint().height()
+ else:
+ tbs_height = 0
 
 # resize the main window so it will display the canvas with the
 # requested size:
 cs = canvas.sizeHint()
- tbs = self.toolbar.sizeHint()
 sbs = self.window.statusBar().sizeHint()
- self.window.resize(cs.width(), cs.height()+tbs.height()+sbs.height())
+ self.window.resize(cs.width(), cs.height()+tbs_height+sbs.height())
 
 self.window.setCentralWidget(self.canvas)
 
@@ -335,7 +339,8 @@
 
 def notify_axes_change( fig ):
 # This will be called whenever the current axes is changed
- if self.toolbar != None: self.toolbar.update()
+ if self.toolbar is not None:
+ self.toolbar.update()
 self.canvas.figure.add_axobserver( notify_axes_change )
 
 def _widgetclosed( self ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8435
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8435&view=rev
Author: efiring
Date: 2010年06月14日 05:51:06 +0000 (2010年6月14日)
Log Message:
-----------
cutils.py: fix and clarify absolute imports, so I don't get confused next time
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/config/cutils.py
Modified: trunk/matplotlib/lib/matplotlib/config/cutils.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/config/cutils.py	2010年06月14日 05:31:20 UTC (rev 8434)
+++ trunk/matplotlib/lib/matplotlib/config/cutils.py	2010年06月14日 05:51:06 UTC (rev 8435)
@@ -8,9 +8,10 @@
 import tempfile
 import warnings
 
-# matplotlib imports
-from matplotlib.verbose import verbose
-from matplotlib.rcsetup import defaultParams
+# imports from local modules that duplicate
+# functionality in matplotlib.__init__
+from matplotlib.config.verbose import verbose
+from matplotlib.config.rcsetup import defaultParams
 
 def is_string_like(obj):
 try: obj + ''
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月14日 05:31:26
Revision: 8434
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8434&view=rev
Author: efiring
Date: 2010年06月14日 05:31:20 +0000 (2010年6月14日)
Log Message:
-----------
[2895114] _get_data_path: improve py2exe handling and readability.
Also convert some imports to absolute.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/__init__.py
 trunk/matplotlib/lib/matplotlib/config/cutils.py
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py	2010年06月14日 02:53:59 UTC (rev 8433)
+++ trunk/matplotlib/lib/matplotlib/__init__.py	2010年06月14日 05:31:20 UTC (rev 8434)
@@ -126,8 +126,10 @@
 
 import sys, os, tempfile
 
-from rcsetup import defaultParams, validate_backend, validate_toolbar
-from rcsetup import validate_cairo_format
+from matplotlib.rcsetup import (defaultParams,
+ validate_backend,
+ validate_toolbar,
+ validate_cairo_format)
 
 major, minor1, minor2, s, tmp = sys.version_info
 _python24 = major>=2 and minor1>=4
@@ -478,28 +480,33 @@
 return path
 
 path = os.sep.join([os.path.dirname(__file__), 'mpl-data'])
- if os.path.isdir(path): return path
+ if os.path.isdir(path):
+ return path
 
 # setuptools' namespace_packages may highjack this init file
 # so need to try something known to be in matplotlib, not basemap
 import matplotlib.afm
 path = os.sep.join([os.path.dirname(matplotlib.afm.__file__), 'mpl-data'])
- if os.path.isdir(path): return path
+ if os.path.isdir(path):
+ return path
 
 # py2exe zips pure python, so still need special check
 if getattr(sys,'frozen',None):
- path = os.path.join(os.path.split(sys.path[0])[0], 'mpl-data')
- if os.path.isdir(path): return path
- else:
- # Try again assuming we need to step up one more directory
- path = os.path.join(os.path.split(os.path.split(sys.path[0])[0])[0],
- 'mpl-data')
- if os.path.isdir(path): return path
- else:
- # Try again assuming sys.path[0] is a dir not a exe
- path = os.path.join(sys.path[0], 'mpl-data')
- if os.path.isdir(path): return path
+ exe_path = os.path.dirname(sys.executable)
+ path = os.path.join(exe_path, 'mpl-data')
+ if os.path.isdir(path):
+ return path
 
+ # Try again assuming we need to step up one more directory
+ path = os.path.join(os.path.split(exe_path)[0], 'mpl-data')
+ if os.path.isdir(path):
+ return path
+
+ # Try again assuming sys.path[0] is a dir not a exe
+ path = os.path.join(sys.path[0], 'mpl-data')
+ if os.path.isdir(path):
+ return path
+
 raise RuntimeError('Could not find the matplotlib data files')
 
 def _get_data_path_cached():
@@ -813,11 +820,12 @@
 if NEWCONFIG:
 #print "importing from reorganized config system!"
 try:
- from config import rcParams, rcdefaults, mplConfig, save_config
+ from matplotlib.config import (rcParams, rcdefaults,
+ mplConfig, save_config)
 verbose.set_level(rcParams['verbose.level'])
 verbose.set_fileo(rcParams['verbose.fileo'])
 except:
- from config import rcParams, rcdefaults
+ from matplotlib.config import rcParams, rcdefaults
 
 _use_error_msg = """ This call to matplotlib.use() has no effect
 because the the backend has already been chosen;
Modified: trunk/matplotlib/lib/matplotlib/config/cutils.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/config/cutils.py	2010年06月14日 02:53:59 UTC (rev 8433)
+++ trunk/matplotlib/lib/matplotlib/config/cutils.py	2010年06月14日 05:31:20 UTC (rev 8434)
@@ -9,8 +9,8 @@
 import warnings
 
 # matplotlib imports
-from verbose import verbose
-from rcsetup import defaultParams
+from matplotlib.verbose import verbose
+from matplotlib.rcsetup import defaultParams
 
 def is_string_like(obj):
 try: obj + ''
@@ -92,6 +92,10 @@
 def _get_data_path():
 'get the path to matplotlib data'
 
+## The following is duplicated in matplotlib.__init__
+def _get_data_path():
+ 'get the path to matplotlib data'
+
 if 'MATPLOTLIBDATA' in os.environ:
 path = os.environ['MATPLOTLIBDATA']
 if not os.path.isdir(path):
@@ -99,30 +103,36 @@
 return path
 
 path = os.sep.join([os.path.dirname(__file__), 'mpl-data'])
- if os.path.isdir(path): return path
+ if os.path.isdir(path):
+ return path
 
 # setuptools' namespace_packages may highjack this init file
 # so need to try something known to be in matplotlib, not basemap
 import matplotlib.afm
 path = os.sep.join([os.path.dirname(matplotlib.afm.__file__), 'mpl-data'])
- if os.path.isdir(path): return path
+ if os.path.isdir(path):
+ return path
 
 # py2exe zips pure python, so still need special check
 if getattr(sys,'frozen',None):
- path = os.path.join(os.path.split(sys.path[0])[0], 'mpl-data')
- if os.path.isdir(path): return path
- else:
- # Try again assuming we need to step up one more directory
- path = os.path.join(os.path.split(os.path.split(sys.path[0])[0])[0],
- 'mpl-data')
- if os.path.isdir(path): return path
- else:
- # Try again assuming sys.path[0] is a dir not a exe
- path = os.path.join(sys.path[0], 'mpl-data')
- if os.path.isdir(path): return path
+ exe_path = os.path.dirname(sys.executable)
+ path = os.path.join(exe_path, 'mpl-data')
+ if os.path.isdir(path):
+ return path
 
+ # Try again assuming we need to step up one more directory
+ path = os.path.join(os.path.split(exe_path)[0], 'mpl-data')
+ if os.path.isdir(path):
+ return path
+
+ # Try again assuming sys.path[0] is a dir not a exe
+ path = os.path.join(sys.path[0], 'mpl-data')
+ if os.path.isdir(path):
+ return path
+
 raise RuntimeError('Could not find the matplotlib data files')
 
+
 def _get_data_path_cached():
 if defaultParams['datapath'][0] is None:
 defaultParams['datapath'][0] = _get_data_path()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月14日 02:54:05
Revision: 8433
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8433&view=rev
Author: efiring
Date: 2010年06月14日 02:53:59 +0000 (2010年6月14日)
Log Message:
-----------
cbook: handle empty string returned by locale.getpreferredencoding
Reported by Huziy Oleksandr.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/cbook.py
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py	2010年06月14日 02:33:37 UTC (rev 8432)
+++ trunk/matplotlib/lib/matplotlib/cbook.py	2010年06月14日 02:53:59 UTC (rev 8433)
@@ -23,11 +23,14 @@
 # On some systems, locale.getpreferredencoding returns None,
 # which can break unicode; and the sage project reports that
 # some systems have incorrect locale specifications, e.g.,
-# an encoding instead of a valid locale name.
+# an encoding instead of a valid locale name. Another
+# pathological case that has been reported is an empty string.
 
 try:
- preferredencoding = locale.getpreferredencoding()
-except (ValueError, ImportError):
+ preferredencoding = locale.getpreferredencoding().strip()
+ if not preferredencoding:
+ preferredencoding = None
+except (ValueError, ImportError, AttributeError):
 preferredencoding = None
 
 def unicode_safe(s):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月14日 02:33:43
Revision: 8432
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8432&view=rev
Author: efiring
Date: 2010年06月14日 02:33:37 +0000 (2010年6月14日)
Log Message:
-----------
[3015614] give examples/api/font_file.py a fighting chance on Linux and Win
Modified Paths:
--------------
 trunk/matplotlib/examples/api/font_file.py
Modified: trunk/matplotlib/examples/api/font_file.py
===================================================================
--- trunk/matplotlib/examples/api/font_file.py	2010年06月14日 01:49:12 UTC (rev 8431)
+++ trunk/matplotlib/examples/api/font_file.py	2010年06月14日 02:33:37 UTC (rev 8432)
@@ -1,19 +1,40 @@
-# -*- noplot -*-
-"""
-Although it is usually not a good idea to explicitly point to a single
-ttf file for a font instance, you can do so using the
-font_manager.FontProperties fname argument (for a more flexible
-solution, see the font_fmaily_rc.py and fonts_demo.py examples).
-"""
-import matplotlib.font_manager as fm
-
-import matplotlib.pyplot as plt
-
-fig = plt.figure()
-ax = fig.add_subplot(111)
-ax.plot([1,2,3])
-
-prop = fm.FontProperties(fname='/Library/Fonts/Tahoma.ttf')
-ax.set_title('this is a special font', fontproperties=prop)
-plt.show()
-
+# -*- noplot -*-
+"""
+Although it is usually not a good idea to explicitly point to a single
+ttf file for a font instance, you can do so using the
+font_manager.FontProperties fname argument (for a more flexible
+solution, see the font_fmaily_rc.py and fonts_demo.py examples).
+"""
+import sys
+import os
+import matplotlib.font_manager as fm
+
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot([1,2,3])
+
+if sys.platform == 'win32':
+ fpath = 'C:\\Windows\\Fonts\\Tahoma.ttf'
+elif sys.platform == 'linux2':
+ fonts = ['/usr/share/fonts/truetype/freefont/FreeSansBoldOblique.ttf',
+ '/usr/share/fonts/truetype/ttf-liberation/LiberationSans-BoldItalic.ttf',
+ '/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf',
+ ]
+ for fpath in fonts:
+ if os.path.exists(fpath):
+ break
+else:
+ fpath = '/Library/Fonts/Tahoma.ttf'
+
+if os.path.exists(fpath):
+ prop = fm.FontProperties(fname=fpath)
+ fname = os.path.split(fpath)[1]
+ ax.set_title('this is a special font: %s' % fname, fontproperties=prop)
+else:
+ ax.set_title('Demo fails--cannot find a demo font')
+ax.set_xlabel('This is the default font')
+
+plt.show()
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月14日 01:49:18
Revision: 8431
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8431&view=rev
Author: efiring
Date: 2010年06月14日 01:49:12 +0000 (2010年6月14日)
Log Message:
-----------
numpy version check: make it more readable
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/__init__.py
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py	2010年06月14日 01:17:23 UTC (rev 8430)
+++ trunk/matplotlib/lib/matplotlib/__init__.py	2010年06月14日 01:49:12 UTC (rev 8431)
@@ -145,12 +145,10 @@
 raise ImportError('matplotlib requires Python 2.4 or later')
 
 import numpy
-nn = numpy.__version__.split('.')
-if not (int(nn[0]) >= 1 and int(nn[1]) >= 1):
- if not (int(nn[0]) >= 2):
- raise ImportError(
- 'numpy 1.1 or later is required; you have %s' %
- numpy.__version__)
+nmajor, nminor = [int(n) for n in numpy.__version__.split('.')[:2]]
+if not (nmajor > 1 or (nmajor == 1 and nminor >= 1)):
+ raise ImportError(
+ 'numpy 1.1 or later is required; you have %s' % numpy.__version__)
 
 def is_string_like(obj):
 if hasattr(obj, 'shape'): return 0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing results of 126

<< < 1 2 3 4 .. 6 > >> (Page 2 of 6)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /