You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
| 2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
| 2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
| 2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ef...@us...> - 2008-04-28 07:42:59
|
Revision: 5086
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5086&view=rev
Author: efiring
Date: 2008-04-28 00:41:25 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
Add hexbin to one more place in boilerplate.py
Modified Paths:
--------------
trunk/matplotlib/boilerplate.py
Modified: trunk/matplotlib/boilerplate.py
===================================================================
--- trunk/matplotlib/boilerplate.py 2008-04-28 07:36:37 UTC (rev 5085)
+++ trunk/matplotlib/boilerplate.py 2008-04-28 07:41:25 UTC (rev 5086)
@@ -99,6 +99,7 @@
cmappable = {
'contour' : 'if ret._A is not None: gci._current = ret',
'contourf': 'if ret._A is not None: gci._current = ret',
+ 'hexbin' : 'gci._current = ret',
'scatter' : 'gci._current = ret',
'pcolor' : 'gci._current = ret',
'pcolormesh' : 'gci._current = ret',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-28 07:36:49
|
Revision: 5085
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5085&view=rev
Author: efiring
Date: 2008-04-28 00:36:37 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
removed dead code from end of colorbar.py
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/colorbar.py
Modified: trunk/matplotlib/lib/matplotlib/colorbar.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colorbar.py 2008-04-28 07:24:33 UTC (rev 5084)
+++ trunk/matplotlib/lib/matplotlib/colorbar.py 2008-04-28 07:36:37 UTC (rev 5085)
@@ -667,36 +667,3 @@
''' % make_axes_kw_doc
-'''
-The following does not work correctly. The problem seems to be that
-the transforms work right only when fig.add_axes(rect) is used to
-generate the axes, not when the axes object is generated first and
-then fig.add_axes(ax) is called. I don't understand this. - EF
-
-class ColorbarAxes(axes.Axes):
- def __init__(self, parent, **kw):
- orientation = kw.setdefault('orientation', 'vertical')
- fraction = kw.pop('fraction', 0.15)
- shrink = kw.pop('shrink', 1.0)
- aspect = kw.pop('aspect', 20)
- self.cbkw = kw
- pb = transforms.PBox(parent.get_position())
- if orientation == 'vertical':
- pb1, pbcb = pb.splitx(1.0-fraction)
- pbcb.shrink(1.0, shrink).anchor('C')
- anchor = (0.3, 0.5)
- panchor = (0.8, 0.5)
- else:
- pbcb, pb1 = pb.splity(fraction)
- pbcb.shrink(shrink, 1.0).anchor('C')
- aspect = 1.0/aspect
- anchor = (0.5, 0.2)
- panchor = (0.5, 0.8)
- parent.set_position(pb1)
- parent.set_anchor(panchor)
- fig = parent.get_figure()
- axes.Axes.__init__(self, fig, pbcb)
- fig.add_axes(self)
- self.set_aspect(aspect, anchor=anchor, adjustable='box')
-
-'''
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-28 07:25:12
|
Revision: 5084
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5084&view=rev
Author: efiring
Date: 2008-04-28 00:24:33 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
Added hexbin axes method and pyplot function by Michiel de Hoon.
Tracker 1952339.
Modified Paths:
--------------
trunk/matplotlib/API_CHANGES
trunk/matplotlib/CHANGELOG
trunk/matplotlib/boilerplate.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/pyplot.py
Modified: trunk/matplotlib/API_CHANGES
===================================================================
--- trunk/matplotlib/API_CHANGES 2008-04-28 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/API_CHANGES 2008-04-28 07:24:33 UTC (rev 5084)
@@ -1,3 +1,7 @@
+ New axes method and pyplot function, hexbin, is an alternative
+ to scatter for large datasets. It makes something like a
+ pcolor of a 2-D histogram, but uses hexagonal bins.
+
New kwarg, "symmetric", in MaxNLocator
allows one require an axis to be centered on zero.
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-28 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/CHANGELOG 2008-04-28 07:24:33 UTC (rev 5084)
@@ -1,3 +1,6 @@
+2008-04-27 Applied patch by Michiel de Hoon to add hexbin
+ axes method and pyplot function - EF
+
2008-04-25 Enforce python >= 2.4; remove subprocess build - EF
2008-04-25 Enforce the numpy requirement at build time - JDH
Modified: trunk/matplotlib/boilerplate.py
===================================================================
--- trunk/matplotlib/boilerplate.py 2008-04-28 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/boilerplate.py 2008-04-28 07:24:33 UTC (rev 5084)
@@ -63,6 +63,7 @@
'csd',
'errorbar',
'fill',
+ 'hexbin',
'hist',
'hlines',
'imshow',
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 07:24:33 UTC (rev 5084)
@@ -4417,6 +4417,229 @@
scatter.__doc__ = cbook.dedent(scatter.__doc__) % martist.kwdocd
+ def hexbin(self, x, y, gridsize = 100, bins = None,
+ xscale = 'linear', yscale = 'linear',
+ cmap=None, norm=None, vmin=None, vmax=None,
+ alpha=1.0, linewidths=None, edgecolors='none',
+ **kwargs):
+ """
+ HEXBIN(x, y, gridsize = 100, bins = None,
+ xscale = 'linear', yscale = 'linear',
+ cmap=None, norm=None, vmin=None, vmax=None,
+ alpha=1.0, linewidths=None, edgecolors='none'
+ **kwargs)
+
+ Make a hexagonal binning plot of x versus y, where x, y are 1-D
+ sequences of the same length, N.
+
+ Either or both of x and y may be masked arrays, in which case all
+ masks will be combined and only unmasked points will be plotted.
+
+ * gridsize=100 : The number of hexagons in the x-direction. The
+ corresponding number of hexagons in the
+ y-direction is chosen such that the hexagons are
+ approximately regular.
+ Alternatively, gridsize can be a tuple with two
+ elements specifying the number of hexagons in
+ the x-direction and the y-direction.
+
+ * bins=None : If None, no binning is applied; the color of
+ each hexagon directly corresponds to its count
+ value.
+ bins='log' : Use a logarithmic scale for the color map.
+ Internally, log(count+1) is used to determine
+ the hexagon color.
+ bins=<integer> : Divide the counts in the specified number of
+ bins, and color the hexagons accordingly
+ bins=<a sequence of values> :
+ The values of the lower bound of the bins
+ to be used.
+
+ * xscale = 'linear' | 'log':
+ Use a logarithmic scale on the horizontal axis.
+
+ * yscale = 'linear' | 'log':
+ Use a logarithmic scale on the vertical axis.
+
+ Other keyword args; the color mapping and normalization arguments.
+
+ * cmap = cm.jet : a colors.Colormap instance from cm.
+ defaults to rc image.cmap
+
+ * norm = colors.Normalize() : colors.Normalize instance
+ is used to scale luminance data to 0,1.
+
+ * vmin=None and vmax=None : vmin and vmax are used in conjunction
+ with norm to normalize luminance data. If either are None, the
+ min and max of the color array C is used. Note if you pass a norm
+ instance, your settings for vmin and vmax will be ignored
+
+ * alpha =1.0 : the alpha value for the patches
+
+ * linewidths, if None, defaults to (lines.linewidth,). Note
+ that this is a tuple, and if you set the linewidths
+ argument you must set it as a sequence of floats, as
+ required by RegularPolyCollection -- see
+ collections.RegularPolyCollection for details
+
+ Optional kwargs control the Collection properties; in
+ particular:
+
+ edgecolors='none' : Draw the edges in the same color
+ as the fill color. This is the default, as
+ it avoids unsightly unpainted pixels
+ between the hexagons.
+ edgecolors=None : Draw the outlines in the default color.
+ edgecolors=<a matplotlib color arg or sequence of rgba tuples>
+ : Draw the outlines in the specified color.
+
+ Here are the standard descriptions of all the Collection kwargs:
+ %(Collection)s
+
+ The return value is a PolyCollection instance; use get_array() on
+ this PolyCollection to get the counts in each hexagon.
+ """
+
+ if not self._hold: self.cla()
+
+ self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
+
+ x, y = delete_masked_points(x, y)
+
+ # Set the size of the hexagon grid
+ if iterable(gridsize):
+ nx, ny = gridsize
+ else:
+ nx = gridsize
+ ny = int(nx/math.sqrt(3))
+ # Count the number of data in each hexagon
+ x = npy.array(x, float)
+ y = npy.array(y, float)
+ if xscale=='log':
+ x = npy.log(x)
+ if yscale=='log':
+ y = npy.log(y)
+ xmin = min(x)
+ xmax = max(x)
+ ymin = min(y)
+ ymax = max(y)
+ # In the x-direction, the hexagons exactly cover the region from
+ # xmin to xmax. Need some padding to avoid roundoff errors.
+ width = xmax - xmin
+ padding = 1.e-9 * width
+ xmin -= padding
+ xmax += padding
+ sx = (xmax-xmin) / nx
+ sy = (ymax-ymin) / ny
+ x = (x-xmin)/sx
+ y = (y-ymin)/sy
+ ix1 = npy.round(x)
+ iy1 = npy.round(y)
+ ix2 = npy.floor(x)
+ iy2 = npy.floor(y)
+
+ nx1 = nx + 1
+ ny1 = ny + 1
+ nx2 = nx
+ ny2 = ny
+ n = nx1*ny1+nx2*ny2
+ counts = npy.zeros(n)
+ lattice1 = counts[:nx1*ny1]
+ lattice2 = counts[nx1*ny1:]
+ lattice1.shape = (nx1,ny1)
+ lattice2.shape = (nx2,ny2)
+
+ d1 = (x-ix1)**2 + 3.0 * (y-iy1)**2
+ d2 = (x-ix2-0.5)**2 + 3.0 * (y-iy2-0.5)**2
+
+ for i in xrange(len(x)):
+ if d1[i] < d2[i]:
+ lattice1[ix1[i], iy1[i]]+=1
+ else:
+ lattice2[ix2[i], iy2[i]]+=1
+
+ px = xmin + sx * npy.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
+ py = ymin + sy * npy.array([-0.5, 0.5 ,1.0, 0.5, -0.5, -1.0]) / 3.0
+
+ polygons = npy.zeros((6, n, 2), float)
+ polygons[:,:nx1*ny1,0] = npy.repeat(npy.arange(nx1), ny1)
+ polygons[:,:nx1*ny1,1] = npy.array(range(ny1) * nx1)
+ polygons[:,nx1*ny1:,0] = npy.repeat(npy.arange(nx2) + 0.5, ny2)
+ polygons[:,nx1*ny1:,1] = npy.array(range(ny2) * nx2) + 0.5
+
+ polygons = npy.transpose(polygons, axes=[1,0,2])
+ polygons[:,:,0] *= sx
+ polygons[:,:,1] *= sy
+ polygons[:,:,0] += px
+ polygons[:,:,1] += py
+
+ if xscale=='log':
+ polygons[:,:,0] = npy.exp(polygons[:,:,0])
+ xmin = math.exp(xmin)
+ xmax = math.exp(xmax)
+ self.set_xscale('log')
+ if yscale=='log':
+ polygons[:,:,1] = npy.exp(polygons[:,:,1])
+ ymin = math.exp(ymin)
+ ymax = math.exp(ymax)
+ self.set_yscale('log')
+
+ class HexagonBinCollection(mcoll.PolyCollection):
+ """A HexagonBinCollection is a PolyCollection where the edge
+ colors are always kept equal to the fill colors"""
+ def update_scalarmappable(self):
+ mcoll.PolyCollection.update_scalarmappable(self)
+ self._edgecolors = self._facecolors
+
+ if edgecolors=='none':
+ collection = HexagonBinCollection(
+ polygons,
+ linewidths = linewidths,
+ transOffset = self.transData,
+ )
+ else:
+ collection = mcoll.PolyCollection(
+ polygons,
+ edgecolors = edgecolors,
+ linewidths = linewidths,
+ transOffset = self.transData,
+ )
+
+ # Transform the counts if needed
+ if bins=='log':
+ counts = npy.log(counts+1)
+ elif bins!=None:
+ if not iterable(bins):
+ minimum, maximum = min(counts), max(counts)
+ bins-=1 # one less edge than bins
+ bins = minimum + (maximum-minimum)*npy.arange(bins)/bins
+ bins = npy.sort(bins)
+ counts = bins.searchsorted(counts)
+
+ if norm is not None: assert(isinstance(norm, mcolors.Normalize))
+ if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
+ collection.set_array(counts)
+ collection.set_cmap(cmap)
+ collection.set_norm(norm)
+ collection.set_alpha(alpha)
+ collection.update(kwargs)
+
+ if vmin is not None or vmax is not None:
+ collection.set_clim(vmin, vmax)
+ else:
+ collection.autoscale_None()
+
+ corners = ((xmin, ymin), (xmax, ymax))
+ self.update_datalim( corners)
+ self.autoscale_view()
+
+ # add the collection last
+ self.add_collection(collection)
+ return collection
+
+ hexbin.__doc__ = cbook.dedent(hexbin.__doc__) % martist.kwdocd
+
+
def arrow(self, x, y, dx, dy, **kwargs):
"""
Draws arrow on specified axis from (x,y) to (x+dx,y+dy).
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-04-28 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-04-28 07:24:33 UTC (rev 5084)
@@ -1953,6 +1953,27 @@
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
+def hexbin(*args, **kwargs):
+ # allow callers to override the hold state by passing hold=True|False
+ b = ishold()
+ h = kwargs.pop('hold', None)
+ if h is not None:
+ hold(h)
+ try:
+ ret = gca().hexbin(*args, **kwargs)
+ draw_if_interactive()
+ except:
+ hold(b)
+ raise
+ gci._current = ret
+ hold(b)
+ return ret
+if Axes.hexbin.__doc__ is not None:
+ hexbin.__doc__ = dedent(Axes.hexbin.__doc__) + """
+Additional kwargs: hold = [True|False] overrides default hold state"""
+
+# This function was autogenerated by boilerplate.py. Do not edit as
+# changes will be lost
def semilogx(*args, **kwargs):
# allow callers to override the hold state by passing hold=True|False
b = ishold()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-28 01:59:18
|
Revision: 5083
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5083&view=rev
Author: efiring
Date: 2008-04-27 18:59:05 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
Fixed bug in last commit
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-04-28 01:37:07 UTC (rev 5082)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-04-28 01:59:05 UTC (rev 5083)
@@ -854,10 +854,12 @@
if fill:
- self.set_color(store=0, *rgbFace[:3])
if stroke:
- write("gsave\nfill\ngrestore\n")
+ write("gsave\n")
+ self.set_color(store=0, *rgbFace[:3])
+ write("fill\ngrestore\n")
else:
+ self.set_color(store=0, *rgbFace[:3])
write("fill\n")
if stroke:
write("stroke\n")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-28 01:37:19
|
Revision: 5082
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5082&view=rev
Author: efiring
Date: 2008-04-27 18:37:07 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
Alternative fix for ps backend bug; removes superfluous gsave/grestores.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-04-28 01:22:19 UTC (rev 5081)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-04-28 01:37:07 UTC (rev 5082)
@@ -469,7 +469,7 @@
def draw_path(self, gc, path, transform, rgbFace=None):
"""
Draws a Path instance using the given affine transform.
- """
+ """
ps = self._convert_path(path, transform)
self._draw_ps(ps, gc, rgbFace)
@@ -744,10 +744,14 @@
""" % locals()
self._pswriter.write(ps)
- def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
+ def _draw_ps_oldstyle(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
"""
Emit the PostScript sniplet 'ps' with all the attributes from 'gc'
applied. 'ps' must consist of PostScript commands to construct a path.
+
+ This is the JDH-modified version of the original. It is kept
+ here now to facilitate checking the version below until we converge.
+
"""
# local variable eliminates all repeated attribute lookups
write = self._pswriter.write
@@ -777,15 +781,6 @@
id = self._get_clip_path(clippath, clippath_trans)
write('gsave\n%s\n' % id)
- needwrap = not (clippath or cliprect)
- if needwrap:
- # we need to make sure that there is at least 1
- # save/grestore around each ps write so we'll force it if
- # we're not getting one from the cliprecot or clippath.
- # hackish, yes
- write('gsave\n')
-
-
# Jochen, is the strip necessary? - this could be a honking big string
write(ps.strip())
write("\n")
@@ -809,10 +804,68 @@
write("grestore\n")
if cliprect:
write("grestore\n")
- if needwrap:
- write('grestore\n')
+ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
+ """
+ Emit the PostScript sniplet 'ps' with all the attributes from 'gc'
+ applied. 'ps' must consist of PostScript commands to construct a path.
+
+ The fill and/or stroke kwargs can be set to False if the
+ 'ps' string already includes filling and/or stroking, in
+ which case _draw_ps is just supplying properties and
+ clipping.
+ """
+ # local variable eliminates all repeated attribute lookups
+ write = self._pswriter.write
+ if debugPS and command:
+ write("% "+command+"\n")
+ write('gsave\n')
+ stroke = (stroke and gc.get_linewidth() > 0.0 and
+ (len(gc.get_rgb()) <= 3 or gc.get_rgb()[3] != 0.0))
+ fill = (fill and rgbFace is not None and
+ (len(rgbFace) <= 3 or rgbFace[3] != 0.0))
+
+ if stroke:
+ self.set_linewidth(gc.get_linewidth())
+ jint = gc.get_joinstyle()
+ self.set_linejoin(jint)
+ cint = gc.get_capstyle()
+ self.set_linecap(cint)
+ self.set_linedash(*gc.get_dashes())
+ self.set_color(*gc.get_rgb()[:3])
+
+ cliprect = gc.get_clip_rectangle()
+ if cliprect:
+ x,y,w,h=cliprect.bounds
+ write('%1.4g %1.4g %1.4g %1.4g clipbox\n' % (w,h,x,y))
+ clippath, clippath_trans = gc.get_clip_path()
+ if clippath:
+ id = self._get_clip_path(clippath, clippath_trans)
+ write('%s\n' % id)
+
+ # Jochen, is the strip necessary? - this could be a honking big string
+ write(ps.strip())
+ write("\n")
+
+ hatch = gc.get_hatch()
+ if hatch:
+ self.set_hatch(hatch)
+
+
+ if fill:
+ self.set_color(store=0, *rgbFace[:3])
+ if stroke:
+ write("gsave\nfill\ngrestore\n")
+ else:
+ write("fill\n")
+ if stroke:
+ write("stroke\n")
+
+ write("grestore\n")
+
+
+
class GraphicsContextPS(GraphicsContextBase):
def get_capstyle(self):
return {'butt':0,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-28 01:22:36
|
Revision: 5081
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5081&view=rev
Author: jdh2358
Date: 2008-04-27 18:22:19 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
fixed a ps path collection bug where cliprect and clipapth are none
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-04-28 00:50:17 UTC (rev 5080)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-04-28 01:22:19 UTC (rev 5081)
@@ -777,6 +777,15 @@
id = self._get_clip_path(clippath, clippath_trans)
write('gsave\n%s\n' % id)
+ needwrap = not (clippath or cliprect)
+ if needwrap:
+ # we need to make sure that there is at least 1
+ # save/grestore around each ps write so we'll force it if
+ # we're not getting one from the cliprecot or clippath.
+ # hackish, yes
+ write('gsave\n')
+
+
# Jochen, is the strip necessary? - this could be a honking big string
write(ps.strip())
write("\n")
@@ -800,6 +809,8 @@
write("grestore\n")
if cliprect:
write("grestore\n")
+ if needwrap:
+ write('grestore\n')
class GraphicsContextPS(GraphicsContextBase):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-28 00:50:25
|
Revision: 5080
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5080&view=rev
Author: efiring
Date: 2008-04-27 17:50:17 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
Fix invalid title string that broke ps output
Modified Paths:
--------------
trunk/matplotlib/examples/nan_test.py
Modified: trunk/matplotlib/examples/nan_test.py
===================================================================
--- trunk/matplotlib/examples/nan_test.py 2008-04-27 07:55:03 UTC (rev 5079)
+++ trunk/matplotlib/examples/nan_test.py 2008-04-28 00:50:17 UTC (rev 5080)
@@ -11,10 +11,7 @@
xlabel('time (s)')
ylabel('voltage (mV)')
-title('A sine wave with a gap of NaN\'s between 0.4 and 0.6')
+title('A sine wave with a gap of NaNs between 0.4 and 0.6')
grid(True)
-#savefig('simple_plot.png')
-savefig('nan_test')
-
show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-27 07:55:07
|
Revision: 5079
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5079&view=rev
Author: efiring
Date: 2008-04-27 00:55:03 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
Handle changed dpi in quiver; remove extra draw in print_figure.
There is still a dpi-related problem with mathtext in the QuiverKey label.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
trunk/matplotlib/lib/matplotlib/mathtext.py
trunk/matplotlib/lib/matplotlib/quiver.py
trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-04-27 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-04-27 07:55:03 UTC (rev 5079)
@@ -1088,8 +1088,7 @@
self.figure.set_facecolor(origfacecolor)
self.figure.set_edgecolor(origedgecolor)
self.figure.set_canvas(self)
- self.figure.canvas.draw()
-
+ #self.figure.canvas.draw() ## seems superfluous
return result
def get_default_filetype(self):
@@ -1509,7 +1508,7 @@
if not self._xypress: return
last_a = []
-
+
for cur_xypress in self._xypress:
x, y = event.x, event.y
lastx, lasty, a, ind, lim, trans = cur_xypress
@@ -1528,7 +1527,7 @@
x, y = inverse.transform_point( (x, y) )
Xmin,Xmax=a.get_xlim()
Ymin,Ymax=a.get_ylim()
-
+
# detect twinx,y axes and avoid double zooming
twinx, twiny = False, False
if last_a:
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-04-27 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-04-27 07:55:03 UTC (rev 5079)
@@ -59,8 +59,7 @@
self.width = width
self.height = height
if __debug__: verbose.report('RendererAgg.__init__ width=%s, height=%s'%(width, height), 'debug-annoying')
- self._renderer = _RendererAgg(int(width), int(height), dpi,
- debug=False)
+ self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
if __debug__: verbose.report('RendererAgg.__init__ _RendererAgg done',
'debug-annoying')
self.draw_path = self._renderer.draw_path
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-04-27 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-04-27 07:55:03 UTC (rev 5079)
@@ -1438,8 +1438,8 @@
w: specifies a width
m: is either 'exactly' or 'additional'.
- Thus, hpack(w, exactly) produces a box whose width is exactly w, while
- hpack (w, additional ) yields a box whose width is the natural width
+ Thus, hpack(w, 'exactly') produces a box whose width is exactly w, while
+ hpack (w, 'additional') yields a box whose width is the natural width
plus w. The default values produce a box with the natural width.
node644, node649"""
# I don't know why these get reset in TeX. Shift_amount is pretty
@@ -1502,8 +1502,8 @@
m: is either 'exactly' or 'additional'.
l: a maximum height
- Thus, vpack(h, exactly) produces a box whose width is exactly w, while
- vpack(w, additional) yields a box whose width is the natural width
+ Thus, vpack(h, 'exactly') produces a box whose width is exactly w, while
+ vpack(w, 'additional') yields a box whose width is the natural width
plus w. The default values produce a box with the natural width.
node644, node668"""
# I don't know why these get reset in TeX. Shift_amount is pretty
@@ -2678,7 +2678,6 @@
def parse(self, s, dpi = 72, prop = None):
if prop is None:
prop = FontProperties()
-
cacheKey = (s, dpi, hash(prop))
result = self._cache.get(cacheKey)
if result is not None:
Modified: trunk/matplotlib/lib/matplotlib/quiver.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/quiver.py 2008-04-27 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/quiver.py 2008-04-27 07:55:03 UTC (rev 5079)
@@ -168,20 +168,24 @@
self.coord = kw.pop('coordinates', 'axes')
self.color = kw.pop('color', None)
self.label = label
- self.labelsep = (kw.pop('labelsep', 0.1) * Q.ax.figure.dpi)
+ self._labelsep_inches = kw.pop('labelsep', 0.1)
+ self.labelsep = (self._labelsep_inches * Q.ax.figure.dpi)
def on_dpi_change(fig):
- self.labelsep = (kw.pop('labelsep', 0.1) * fig.dpi)
+ self.labelsep = (self._labelsep_inches * fig.dpi)
+ self._initialized = False # simple brute force update
+ # works because _init is called
+ # at the start of draw.
Q.ax.figure.callbacks.connect('dpi_changed', on_dpi_change)
-
self.labelpos = kw.pop('labelpos', 'N')
self.labelcolor = kw.pop('labelcolor', None)
self.fontproperties = kw.pop('fontproperties', dict())
self.kw = kw
_fp = self.fontproperties
- self.text = text.Text(text=label,
+ #boxprops = dict(facecolor='red')
+ self.text = text.Text(text=label, # bbox=boxprops,
horizontalalignment=self.halign[self.labelpos],
verticalalignment=self.valign[self.labelpos],
fontproperties=font_manager.FontProperties(**_fp))
@@ -297,6 +301,16 @@
self.keyvec = None
self.keytext = None
+ def on_dpi_change(fig):
+ self._new_UV = True # vertices depend on width, span
+ # which in turn depend on dpi
+ self._initialized = False # simple brute force update
+ # works because _init is called
+ # at the start of draw.
+
+ self.ax.figure.callbacks.connect('dpi_changed', on_dpi_change)
+
+
__init__.__doc__ = """
The constructor takes one required argument, an Axes
instance, followed by the args and kwargs described
@@ -331,7 +345,8 @@
if not self._initialized:
trans = self._set_transform()
ax = self.ax
- sx, sy = trans.inverted().transform_point((ax.bbox.width, ax.bbox.height))
+ sx, sy = trans.inverted().transform_point(
+ (ax.bbox.width, ax.bbox.height))
self.span = sx
sn = max(8, min(25, math.sqrt(self.N)))
if self.width is None:
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2008-04-27 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/text.py 2008-04-27 07:55:03 UTC (rev 5079)
@@ -1174,7 +1174,6 @@
if self.arrowprops:
x0, y0 = x, y
l,b,w,h = self.get_window_extent(renderer).bounds
- dpi = self.figure.dpi
r = l+w
t = b+h
xc = 0.5*(l+r)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-27 02:27:06
|
Revision: 5078
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5078&view=rev
Author: jdh2358
Date: 2008-04-26 19:27:01 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
removed backend_agg2
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_template.py
Removed Paths:
-------------
trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py
Deleted: trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2008-04-26 21:59:17 UTC (rev 5077)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2008-04-27 02:27:01 UTC (rev 5078)
@@ -1,206 +0,0 @@
-"""
-An agg http://antigrain.com/ backend
-
-"""
-from __future__ import division
-
-import os, sys
-import matplotlib.agg as agg
-
-from matplotlib import verbose
-
-from matplotlib._pylab_helpers import Gcf
-from matplotlib.backend_bases import RendererBase,\
- GraphicsContextBase, FigureManagerBase, FigureCanvasBase
-
-from matplotlib.cbook import enumerate, is_string_like, exception_to_str
-from matplotlib.figure import Figure
-from matplotlib.ft2font import FT2Font
-from matplotlib.mathtext import MathTextParser
-
-
-from _backend_agg import RendererAgg as _RendererAgg
-
-backend_version = 'v2.2'
-_fontd = {} # a map from fname to font instances
-
-
-class RendererAgg(RendererBase):
- """
- The renderer handles all the drawing primitives using a graphics
- context instance that controls the colors/styles
- """
-
- debug=1
- def __init__(self, width, height, dpi):
- if __debug__: verbose.report('RendererAgg.__init__', 'debug-annoying')
- self.dpi = dpi
- self.width = int(width)
- self.height = int(height)
-
- stride = self.width*4
- self.buffer = agg.buffer(self.width, self.height, stride)
-
- self.rbuf = agg.rendering_buffer()
- self.rbuf.attachb(self.buffer)
-
- self.pf = agg.pixel_format(self.rbuf)
- self.rbase = agg.renderer_base(self.pf)
-
- self.rasterizer = agg.rasterizer_scanline_aa()
- self.scanline = agg.scanline_p8()
- self.renderer = agg.renderer_scanline_aa_solid(self.rbase);
-
-
- def draw_lines(self, gc, x, y, trans):
- """
- x and y are equal length arrays, draw lines connecting each
- point in x, y
- """
-
- x, y = trans.numerix_x_y(x,y)
- if len(x)<2: return
- path = agg.path_storage()
- path.move_to(x[0],self.height-y[0])
- for i in xrange(1, len(x)):
- path.line_to(x[i],self.height-y[i])
-
- stroke = agg.conv_stroke(path)
- stroke.width(1.0)
- r,g,b = [int(255*val) for val in gc.get_rgb()]
- a = int(255*gc.get_alpha())
-
- color = agg.rgba8(r,g,b,a)
- self.renderer.color( color )
- self.rasterizer.add_path(stroke)
- agg.render_scanlines(self.rasterizer, self.scanline, self.renderer);
-
- def draw_markers(self, gc, path, rgbFace, xt, yt, trans):
- pass
-
- def draw_arc(self, gcEdge, rgbFace, x, y, width, height, angle1, angle2, rotation):
- pass
-
- def draw_image(self, x, y, im, origin, bbox):
- pass
-
- def draw_line(self, gc, x1, y1, x2, y2):
- pass
-
- def draw_point(self, gc, x, y):
- pass
-
- def draw_polygon(self, gcEdge, rgbFace, points):
- pass
-
- def draw_rectangle(self, gcEdge, rgbFace, x, y, width, height):
- pass
-
- def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
- pass
-
- def flipy(self):
- return True
-
- def get_canvas_width_height(self):
- return 100, 100
-
- def get_text_width_height(self, s, prop, ismath):
- return 1, 1
-
- def new_gc(self):
- return GraphicsContextBase()
-
-
- def points_to_pixels(self, points):
- """
- convert point measures to pixes using dpi and the pixels per
- inch of the display
- """
- if __debug__: verbose.report('RendererAgg.points_to_pixels', 'debug-annoying')
- return points*self.dpi.get()/72.0
-
-
-
-
-
-def new_figure_manager(num, *args, **kwargs):
- """
- Create a new figure manager instance
- """
- if __debug__: verbose.report('backend_agg.new_figure_manager', 'debug-annoying')
- FigureClass = kwargs.pop('FigureClass', Figure)
- thisFig = FigureClass(*args, **kwargs)
- canvas = FigureCanvasAgg(thisFig)
- manager = FigureManagerBase(canvas, num)
- return manager
-
-
-class FigureCanvasAgg(FigureCanvasBase):
- """
- The canvas the figure renders into. Calls the draw and print fig
- methods, creates the renderers, etc...
-
- Public attribute
-
- figure - A Figure instance
- """
-
-
-
- def draw(self):
- """
- Draw the figure using the renderer
- """
- if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')
-
- renderer = self.get_renderer()
- self.figure.draw(renderer)
- return renderer
-
- def get_renderer(self):
- l,b,w,h = self.figure.bbox.get_bounds()
- key = w, h, self.figure.dpi.get()
- try: self._lastKey, self.renderer
- except AttributeError: need_new_renderer = True
- else: need_new_renderer = (self._lastKey != key)
-
- if need_new_renderer:
- self.renderer = RendererAgg(w, h, self.figure.dpi)
- self._lastKey = key
- return self.renderer
-
- def tostring_rgb(self):
- if __debug__: verbose.report('FigureCanvasAgg.tostring_rgb', 'debug-annoying')
- return self.renderer.tostring_rgb()
-
- def tostring_argb(self):
- if __debug__: verbose.report('FigureCanvasAgg.tostring_argb', 'debug-annoying')
- return self.renderer.tostring_argb()
-
- def buffer_rgba(self,x,y):
- if __debug__: verbose.report('FigureCanvasAgg.buffer_rgba', 'debug-annoying')
- return self.renderer.buffer_rgba(x,y)
-
-
- def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
- orientation='portrait', **kwargs):
- """
- Render the figure to hardcopy. Set the figure patch face and
- edge colors. This is useful because some of the GUIs have a
- gray figure face color background and you'll probably want to
- override this on hardcopy
-
- If the extension matches PNG, write a PNG file
-
- If the extension matches BMP or RAW, write an RGBA bitmap file
-
- If filename is a fileobject, write png to file object (thus
- you can, for example, write the png to stdout
- """
-
- r = self.draw()
- s = r.buffer.to_string()
- import Image
- im = Image.fromstring( "RGBA", (r.width, r.height), s)
- im.show()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_template.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_template.py 2008-04-26 21:59:17 UTC (rev 5077)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_template.py 2008-04-27 02:27:01 UTC (rev 5078)
@@ -68,13 +68,15 @@
def draw_path(self, gc, path, transform, rgbFace=None):
pass
- # draw_markers is optional, and we get more correct
- # relative timings by leaving it out.
+ # draw_markers is optional, and we get more correct relative
+ # timings by leaving it out. backend implementers concerned with
+ # performance will probably want to implement it
# def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None):
# pass
# draw_path_collection is optional, and we get more correct
- # relative timings by leaving it out.
+ # relative timings by leaving it out. backend implementers concerned with
+ # performance will probably want to implement it
# def draw_path_collection(self, master_transform, cliprect, clippath,
# clippath_trans, paths, all_transforms, offsets,
# offsetTrans, facecolors, edgecolors, linewidths,
@@ -82,7 +84,8 @@
# pass
# draw_quad_mesh is optional, and we get more correct
- # relative timings by leaving it out.
+ # relative timings by leaving it out. backend implementers concerned with
+ # performance will probably want to implement it
# def draw_quad_mesh(self, master_transform, cliprect, clippath,
# clippath_trans, meshWidth, meshHeight, coordinates,
# offsets, offsetTrans, facecolors, antialiased,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-26 21:59:20
|
Revision: 5077
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5077&view=rev
Author: jdh2358
Date: 2008-04-26 14:59:17 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
added a dpi callback to the quiver key
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/quiver.py
Modified: trunk/matplotlib/lib/matplotlib/quiver.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/quiver.py 2008-04-26 21:46:52 UTC (rev 5076)
+++ trunk/matplotlib/lib/matplotlib/quiver.py 2008-04-26 21:59:17 UTC (rev 5077)
@@ -169,6 +169,13 @@
self.color = kw.pop('color', None)
self.label = label
self.labelsep = (kw.pop('labelsep', 0.1) * Q.ax.figure.dpi)
+
+ def on_dpi_change(fig):
+ self.labelsep = (kw.pop('labelsep', 0.1) * fig.dpi)
+
+ Q.ax.figure.callbacks.connect('dpi_changed', on_dpi_change)
+
+
self.labelpos = kw.pop('labelpos', 'N')
self.labelcolor = kw.pop('labelcolor', None)
self.fontproperties = kw.pop('fontproperties', dict())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-26 21:46:54
|
Revision: 5076
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5076&view=rev
Author: jdh2358
Date: 2008-04-26 14:46:52 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
fixed dpi figure title positioning problem
Modified Paths:
--------------
trunk/matplotlib/CODING_GUIDE
trunk/matplotlib/Makefile
trunk/matplotlib/examples/barchart_demo.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/figure.py
trunk/matplotlib/lib/matplotlib/pyplot.py
trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/CODING_GUIDE
===================================================================
--- trunk/matplotlib/CODING_GUIDE 2008-04-25 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/CODING_GUIDE 2008-04-26 21:46:52 UTC (rev 5076)
@@ -45,8 +45,8 @@
For numpy, use:
- import numpy as npy
- a = npy.array([1,2,3])
+ import numpy as np
+ a = np.array([1,2,3])
For masked arrays, use:
Modified: trunk/matplotlib/Makefile
===================================================================
--- trunk/matplotlib/Makefile 2008-04-25 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/Makefile 2008-04-26 21:46:52 UTC (rev 5076)
@@ -10,7 +10,7 @@
RELEASE = matplotlib-${VERSION}
-clean:
+clean:
${PYTHON} setup.py clean;\
rm -f *.png *.ps *.eps *.svg *.jpg *.pdf
find . -name "_tmp*.py" | xargs rm -f;\
@@ -25,11 +25,12 @@
${PYTHON} license.py ${VERSION} license/LICENSE;\
${PYTHON} setup.py sdist --formats=gztar,zip;
-pyback:
- tar cvfz pyback.tar.gz *.py lib src examples/*.py unit/*.py
+pyback:
+ tar cvfz pyback.tar.gz *.py lib src examples/*.py unit/*.py
+build_osx105:
+ CFLAGS="-Os -arch i386 -arch ppc" LDFLAGS="-Os -arch i386 -arch ppc" python setup.py build
-
Modified: trunk/matplotlib/examples/barchart_demo.py
===================================================================
--- trunk/matplotlib/examples/barchart_demo.py 2008-04-25 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/examples/barchart_demo.py 2008-04-26 21:46:52 UTC (rev 5076)
@@ -1,24 +1,39 @@
+
#!/usr/bin/env python
# a bar plot with errorbars
-from pylab import *
+import numpy as np
+import matplotlib.pyplot as plt
N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)
-ind = arange(N) # the x locations for the groups
+ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
-p1 = bar(ind, menMeans, width, color='r', yerr=menStd)
+fig = plt.figure()
+ax = fig.add_subplot(111)
+rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
+
womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
-p2 = bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
+rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
-ylabel('Scores')
-title('Scores by group and gender')
-xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') )
+# add some
+ax.set_ylabel('Scores')
+ax.set_title('Scores by group and gender')
+ax.set_xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') )
-legend( (p1[0], p2[0]), ('Men', 'Women') )
+ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
-#savefig('barchart_demo')
-show()
+def autolabel(rects):
+ # attach some text labels
+ for rect in rects:
+ height = rect.get_height()
+ ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height),
+ ha='center', va='bottom')
+
+autolabel(rects1)
+autolabel(rects2)
+#fig.savefig('barchart_demo')
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-25 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-26 21:46:52 UTC (rev 5076)
@@ -780,7 +780,10 @@
self.grid(self._gridOn)
props = font_manager.FontProperties(size=rcParams['axes.titlesize'])
- self.titleOffsetTrans = mtransforms.Affine2D().translate(0.0, 10.0)
+
+
+ self.titleOffsetTrans = mtransforms.Affine2D().translate(
+ 0.0, 5.0*self.figure.dpi/72.)
self.title = mtext.Text(
x=0.5, y=1.0, text='',
fontproperties=props,
@@ -811,8 +814,17 @@
self.xaxis.set_clip_path(self.axesPatch)
self.yaxis.set_clip_path(self.axesPatch)
- self.titleOffsetTrans.clear().translate(0.0, 10.0)
+ self.titleOffsetTrans.clear().translate(
+ 0.0, 5.0*self.figure.dpi/72.)
+ def on_dpi_change(fig):
+ self.titleOffsetTrans.clear().translate(
+ 0.0, 5.0*fig.dpi/72.)
+
+ self.figure.callbacks.connect('dpi_changed', on_dpi_change)
+
+
+
def clear(self):
'clear the axes'
self.cla()
@@ -839,8 +851,10 @@
figure will be cleared on the next plot command
"""
- if b is None: self._hold = not self._hold
- else: self._hold = b
+ if b is None:
+ self._hold = not self._hold
+ else:
+ self._hold = b
def get_aspect(self):
return self._aspect
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2008-04-25 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2008-04-26 21:46:52 UTC (rev 5076)
@@ -1,7 +1,7 @@
"""
Figure class -- add docstring here!
"""
-import numpy as npy
+import numpy as np
import time
import artist
@@ -20,6 +20,8 @@
from projections import projection_factory, get_projection_names, \
get_projection_class
+import matplotlib.cbook as cbook
+
class SubplotParams:
"""
A class to hold the parameters for a subplot
@@ -176,6 +178,13 @@
class Figure(Artist):
+ """
+ The Figure instance supports callbacks through a callbacks
+ attribute which is a cbook.CallbackRegistry instance. The events
+ you can connect to are 'dpi_changed', and the callback will be
+ called with func(fig) where fig is the Figure instance
+ """
+
def __str__(self):
return "Figure(%gx%g)" % tuple(self.bbox.size)
@@ -195,6 +204,8 @@
"""
Artist.__init__(self)
+ self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
+
if figsize is None : figsize = rcParams['figure.figsize']
if dpi is None : dpi = rcParams['figure.dpi']
if facecolor is None: facecolor = rcParams['figure.facecolor']
@@ -236,6 +247,7 @@
def _set_dpi(self, dpi):
self._dpi = dpi
self.dpi_scale_trans.clear().scale(dpi, dpi)
+ self.callbacks.process('dpi_changed', self)
dpi = property(_get_dpi, _set_dpi)
def enable_auto_layout(self, setting=True):
@@ -255,7 +267,7 @@
rotation: the rotation of the xtick labels
ha : the horizontal alignment of the xticklabels
"""
- allsubplots = npy.alltrue([hasattr(ax, 'is_last_row') for ax in self.axes])
+ allsubplots = np.alltrue([hasattr(ax, 'is_last_row') for ax in self.axes])
if len(self.axes)==1:
for label in ax.get_xticklabels():
label.set_ha(ha)
@@ -662,6 +674,9 @@
"""
Clear the figure
"""
+
+ self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
+
for ax in tuple(self.axes): # Iterate over the copy.
ax.cla()
self.delaxes(ax) # removes ax from self.axes
@@ -1022,8 +1037,8 @@
# min/max sizes to respect when autoscaling. If John likes the idea, they
# could become rc parameters, for now they're hardwired.
- figsize_min = npy.array((4.0,2.0)) # min length for width/height
- figsize_max = npy.array((16.0,16.0)) # max length for width/height
+ figsize_min = np.array((4.0,2.0)) # min length for width/height
+ figsize_max = np.array((16.0,16.0)) # max length for width/height
#figsize_min = rcParams['figure.figsize_min']
#figsize_max = rcParams['figure.figsize_max']
@@ -1038,7 +1053,7 @@
fig_height = rcParams['figure.figsize'][1]
# New size for the figure, keeping the aspect ratio of the caller
- newsize = npy.array((fig_height/arr_ratio,fig_height))
+ newsize = np.array((fig_height/arr_ratio,fig_height))
# Sanity checks, don't drop either dimension below figsize_min
newsize /= min(1.0,*(newsize/figsize_min))
@@ -1048,7 +1063,7 @@
# Finally, if we have a really funky aspect ratio, break it but respect
# the min/max dimensions (we don't want figures 10 feet tall!)
- newsize = npy.clip(newsize,figsize_min,figsize_max)
+ newsize = np.clip(newsize,figsize_min,figsize_max)
return newsize
artist.kwdocd['Figure'] = artist.kwdoc(Figure)
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-04-25 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-04-26 21:46:52 UTC (rev 5076)
@@ -274,9 +274,9 @@
def ginput(*args, **kwargs):
"""
- Blocking call to interact with the figure.
+ Blocking call to interact with the figure.
- This will wait for n clicks from the user and return a list of the
+ This will wait for n clicks from the user and return a list of the
coordinates of each click.
If timeout is negative, does not timeout.
@@ -345,8 +345,17 @@
will be cleared on the next plot command
"""
- gcf().hold(b)
- gca().hold(b)
+ fig = gcf()
+ ax = fig.gca()
+
+ fig.hold(b)
+ ax.hold(b)
+
+ # b=None toggles the hold state, so let's get get the current hold
+ # state; but should pyplot hold toggle the rc setting - me thinks
+ # not
+ b = ax.ishold()
+
rc('axes', hold=b)
def ishold():
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2008-04-25 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/lib/matplotlib/text.py 2008-04-26 21:46:52 UTC (rev 5076)
@@ -4,7 +4,7 @@
from __future__ import division
import math
-import numpy as npy
+import numpy as np
from matplotlib import cbook
from matplotlib import rcParams
@@ -180,8 +180,8 @@
width, height = 0.0, 0.0
lines = self._text.split('\n')
- whs = npy.zeros((len(lines), 2))
- horizLayout = npy.zeros((len(lines), 4))
+ whs = np.zeros((len(lines), 2))
+ horizLayout = np.zeros((len(lines), 4))
# Find full vertical extent of font,
# including ascenders and descenders:
@@ -208,7 +208,7 @@
# get the rotation matrix
M = Affine2D().rotate_deg(self.get_rotation())
- offsetLayout = npy.zeros((len(lines), 2))
+ offsetLayout = np.zeros((len(lines), 2))
offsetLayout[:] = horizLayout[:, 0:2]
# now offset the individual text lines within the box
if len(lines)>1: # do the multiline aligment
@@ -219,9 +219,9 @@
offsetLayout[:, 0] += width - horizLayout[:, 2]
# the corners of the unrotated bounding box
- cornersHoriz = npy.array(
+ cornersHoriz = np.array(
[(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)],
- npy.float_)
+ np.float_)
# now rotate the bbox
cornersRotated = M.transform(cornersHoriz)
@@ -658,7 +658,7 @@
dashlength is the length of the dash in canvas units.
(default=0.0).
- dashdirection is one of 0 or 1, npy.where 0 draws the dash
+ dashdirection is one of 0 or 1, np.where 0 draws the dash
after the text and 1 before.
(default=0).
@@ -782,15 +782,15 @@
dashpush = self.get_dashpush()
angle = get_rotation(dashrotation)
- theta = npy.pi*(angle/180.0+dashdirection-1)
- cos_theta, sin_theta = npy.cos(theta), npy.sin(theta)
+ theta = np.pi*(angle/180.0+dashdirection-1)
+ cos_theta, sin_theta = np.cos(theta), np.sin(theta)
transform = self.get_transform()
# Compute the dash end points
# The 'c' prefix is for canvas coordinates
cxy = transform.transform_point((dashx, dashy))
- cd = npy.array([cos_theta, sin_theta])
+ cd = np.array([cos_theta, sin_theta])
c1 = cxy+dashpush*cd
c2 = cxy+(dashpush+dashlength)*cd
@@ -829,8 +829,8 @@
if dy > h or dy < -h:
dy = h
dx = h/tan_theta
- cwd = npy.array([dx, dy])/2
- cwd *= 1+dashpad/npy.sqrt(npy.dot(cwd,cwd))
+ cwd = np.array([dx, dy])/2
+ cwd *= 1+dashpad/np.sqrt(np.dot(cwd,cwd))
cw = c2+(dashdirection*2-1)*cwd
newx, newy = inverse.transform_point(tuple(cw))
@@ -840,7 +840,7 @@
# I'm not at all sure this is the right way to do this.
we = Text.get_window_extent(self, renderer=renderer)
self._twd_window_extent = we.frozen()
- self._twd_window_extent.update_from_data_xy(npy.array([c1]), False)
+ self._twd_window_extent.update_from_data_xy(np.array([c1]), False)
# Finally, make text align center
Text.set_horizontalalignment(self, 'center')
@@ -1094,8 +1094,8 @@
return x, y
elif s=='polar':
theta, r = x, y
- x = r*npy.cos(theta)
- y = r*npy.sin(theta)
+ x = r*np.cos(theta)
+ y = r*np.cosmsin(theta)
trans = self.axes.transData
return trans.transform_point((x,y))
elif s=='figure points':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-25 16:45:36
|
Revision: 5075
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5075&view=rev
Author: efiring
Date: 2008-04-25 09:45:30 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
Enforce python 2.4 or later; some other version-related cleanup
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/__init__.py
trunk/matplotlib/setup.py
trunk/matplotlib/setupext.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-25 15:43:06 UTC (rev 5074)
+++ trunk/matplotlib/CHANGELOG 2008-04-25 16:45:30 UTC (rev 5075)
@@ -1,4 +1,7 @@
+2008-04-25 Enforce python >= 2.4; remove subprocess build - EF
+2008-04-25 Enforce the numpy requirement at build time - JDH
+
2008-04-24 Make numpy 1.1 and python 2.3 required when importing
matplotlib - EF
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2008-04-25 15:43:06 UTC (rev 5074)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-04-25 16:45:30 UTC (rev 5075)
@@ -95,10 +95,8 @@
from rcsetup import validate_cairo_format
major, minor1, minor2, s, tmp = sys.version_info
-_python23 = major>=2 and minor1>=3
+_python24 = major>=2 and minor1>=4
-_havemath = _python23
-
try:
import datetime
import dateutil
@@ -111,14 +109,14 @@
#except ImportError: _have_pkg_resources = False
#else: _have_pkg_resources = True
-if not _python23:
- raise SystemExit('matplotlib requires Python 2.3 or later')
+if not _python24:
+ raise SystemExit('matplotlib requires Python 2.4 or later')
import numpy
nn = numpy.__version__.split('.')
if not (int(nn[0]) >= 1 and int(nn[1]) >= 1):
raise SystemExit(
- 'numpy >= 1.1 is required; you have %s' % numpy.__version__)
+ 'numpy 1.1 or later is required; you have %s' % numpy.__version__)
def is_string_like(obj):
if hasattr(obj, 'shape'): return 0
Modified: trunk/matplotlib/setup.py
===================================================================
--- trunk/matplotlib/setup.py 2008-04-25 15:43:06 UTC (rev 5074)
+++ trunk/matplotlib/setup.py 2008-04-25 16:45:30 UTC (rev 5075)
@@ -20,28 +20,15 @@
import sys
major, minor1, minor2, s, tmp = sys.version_info
-if major==2 and minor1<=3:
- # setuptools monkeypatches distutils.core.Distribution to support
- # package_data
- try: import setuptools
- except ImportError:
- raise SystemExit("""\
-matplotlib requires setuptools for installation with python-2.3. Visit:
-http://cheeseshop.python.org/pypi/setuptools
-for installation instructions for the proper version of setuptools for your
-system. If this is your first time upgrading matplotlib with the new
-setuptools requirement, you must delete the old matplotlib install
-directory.""")
+if major==2 and minor1<4 or major<2:
+ raise SystemExit("""matplotlib requires Python 2.4 or later.""")
-if major==2 and minor1<3 or major<2:
- raise SystemExit("""matplotlib requires Python 2.3 or later.""")
-
import glob
from distutils.core import setup
from setupext import build_agg, build_gtkagg, build_tkagg, build_wxagg,\
build_ft2font, build_image, build_windowing, build_path, \
build_contour, build_nxutils, build_traits, build_gdk, \
- build_subprocess, build_ttconv, print_line, print_status, print_message, \
+ build_ttconv, print_line, print_status, print_message, \
print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \
check_for_tk, check_for_wx, check_for_numpy, check_for_qt, check_for_qt4, \
check_for_cairo, check_provide_traits, check_provide_pytz, \
@@ -100,25 +87,8 @@
]}
if not check_for_numpy():
- sys.exit()
+ sys.exit(1)
-try: import subprocess
-except ImportError: havesubprocess = False
-else: havesubprocess = True
-
-if havesubprocess and sys.version < '2.4':
- # Python didn't come with subprocess, so let's make sure it's
- # not in some Python egg (e.g. an older version of matplotlib)
- # that may get removed.
- subprocess_dir = os.path.dirname(subprocess.__file__)
- if subprocess_dir.endswith('.egg/subprocess'):
- havesubprocess = False
-
-if not havesubprocess:
- packages.append('subprocess')
- if sys.platform == 'win32':
- build_subprocess(ext_modules, packages)
-
if not check_for_freetype():
sys.exit(1)
Modified: trunk/matplotlib/setupext.py
===================================================================
--- trunk/matplotlib/setupext.py 2008-04-25 15:43:06 UTC (rev 5074)
+++ trunk/matplotlib/setupext.py 2008-04-25 16:45:30 UTC (rev 5075)
@@ -532,21 +532,17 @@
return False
def check_for_numpy():
- gotit = False
try:
import numpy
except ImportError:
print_status("numpy", "no")
- print_message("You must install numpy to build matplotlib.")
- return False
-
- major, minor1, minor2 = map(int, numpy.__version__.split('.')[:3])
- if major<1 or (major==1 and minor1<1):
- print_status("numpy version", "no")
print_message("You must install numpy 1.1 or later to build matplotlib.")
-
return False
-
+ nn = numpy.__version__.split('.')
+ if not (int(nn[0]) >= 1 and int(nn[1]) >= 1):
+ print_message(
+ 'numpy 1.1 or later is required; you have %s' % numpy.__version__)
+ return False
module = Extension('test', [])
add_numpy_flags(module)
add_base_flags(module)
@@ -554,16 +550,13 @@
print_status("numpy", numpy.__version__)
if not find_include_file(module.include_dirs, os.path.join("numpy", "arrayobject.h")):
print_message("Could not find the headers for numpy. You may need to install the development package.")
+ return False
return True
def add_numpy_flags(module):
"Add the modules flags to build extensions which use numpy"
import numpy
- # TODO: Remove this try statement when it is no longer needed
- try:
- module.include_dirs.append(numpy.get_include())
- except AttributeError:
- module.include_dirs.append(numpy.get_numpy_include())
+ module.include_dirs.append(numpy.get_include())
def add_agg_flags(module):
'Add the module flags to build extensions which use agg'
@@ -1267,10 +1260,3 @@
BUILT_GDK = True
-def build_subprocess(ext_modules, packages):
- module = Extension(
- 'subprocess._subprocess',
- ['src/_subprocess.c', ],
- )
- add_base_flags(module)
- ext_modules.append(module)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-25 15:43:58
|
Revision: 5074
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5074&view=rev
Author: jdh2358
Date: 2008-04-25 08:43:06 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
added numpy version check at build time
Modified Paths:
--------------
trunk/matplotlib/setupext.py
Modified: trunk/matplotlib/setupext.py
===================================================================
--- trunk/matplotlib/setupext.py 2008-04-24 18:31:10 UTC (rev 5073)
+++ trunk/matplotlib/setupext.py 2008-04-25 15:43:06 UTC (rev 5074)
@@ -539,6 +539,14 @@
print_status("numpy", "no")
print_message("You must install numpy to build matplotlib.")
return False
+
+ major, minor1, minor2 = map(int, numpy.__version__.split('.')[:3])
+ if major<1 or (major==1 and minor1<1):
+ print_status("numpy version", "no")
+ print_message("You must install numpy 1.1 or later to build matplotlib.")
+
+ return False
+
module = Extension('test', [])
add_numpy_flags(module)
add_base_flags(module)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-24 18:31:15
|
Revision: 5073
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5073&view=rev
Author: efiring
Date: 2008-04-24 11:31:10 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Enforce numpy >= 1.1 and python >= 2.3 when importing matplotlib.
Numpy svn passes the test now.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/__init__.py
trunk/matplotlib/lib/matplotlib/transforms.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-24 17:57:57 UTC (rev 5072)
+++ trunk/matplotlib/CHANGELOG 2008-04-24 18:31:10 UTC (rev 5073)
@@ -1,3 +1,7 @@
+
+2008-04-24 Make numpy 1.1 and python 2.3 required when importing
+ matplotlib - EF
+
2008-04-24 Fix compilation issues on VS2003 (Thanks Martin Spacek for
all the help) - MGD
@@ -3443,4 +3447,4 @@
2003-11-21 - make a dash-dot dict for the GC
2003-12-15 - fix install path bug
-t
\ No newline at end of file
+t
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2008-04-24 17:57:57 UTC (rev 5072)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-04-24 18:31:10 UTC (rev 5073)
@@ -112,10 +112,13 @@
#else: _have_pkg_resources = True
if not _python23:
- def enumerate(seq):
- for i in range(len(seq)):
- yield i, seq[i]
+ raise SystemExit('matplotlib requires Python 2.3 or later')
+import numpy
+nn = numpy.__version__.split('.')
+if not (int(nn[0]) >= 1 and int(nn[1]) >= 1):
+ raise SystemExit(
+ 'numpy >= 1.1 is required; you have %s' % numpy.__version__)
def is_string_like(obj):
if hasattr(obj, 'shape'): return 0
Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py 2008-04-24 17:57:57 UTC (rev 5072)
+++ trunk/matplotlib/lib/matplotlib/transforms.py 2008-04-24 18:31:10 UTC (rev 5073)
@@ -693,10 +693,7 @@
if len(xy) == 0:
return
- try:
- xym = ma.masked_invalid(xy) # maybe add copy=False
- except AttributeError: # masked_invalid not exposed in npy 1.04
- xym = ma.masked_where(~npy.isfinite(xy), xy)
+ xym = ma.masked_invalid(xy) # maybe add copy=False
if (xym.count(axis=1)!=2).all():
return
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-24 17:58:04
|
Revision: 5072
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5072&view=rev
Author: mdboom
Date: 2008-04-24 10:57:57 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Trying to fix build for Eric (by including png.h first)
Modified Paths:
--------------
trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp 2008-04-24 13:23:05 UTC (rev 5071)
+++ trunk/matplotlib/src/_image.cpp 2008-04-24 17:57:57 UTC (rev 5072)
@@ -1,3 +1,10 @@
+#include <png.h>
+
+// To remove a gcc warning
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
#include "Python.h" //after png.h due to setjmp bug
#include <string>
@@ -5,7 +12,6 @@
#include <fstream>
#include <cmath>
#include <cstdio>
-#include <png.h>
#define PY_ARRAY_TYPES_PREFIX NumPy
#include "numpy/arrayobject.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-24 13:23:48
|
Revision: 5071
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5071&view=rev
Author: mdboom
Date: 2008-04-24 06:23:05 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Remove a bunch of compiler warnings.
Modified Paths:
--------------
trunk/matplotlib/CXX/WrapPython.h
trunk/matplotlib/agg24/src/agg_curves.cpp
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/_gtkagg.cpp
trunk/matplotlib/src/_image.cpp
trunk/matplotlib/src/_path.cpp
trunk/matplotlib/src/_ttconv.cpp
trunk/matplotlib/src/ft2font.cpp
trunk/matplotlib/src/ft2font.h
trunk/matplotlib/ttconv/pprdrv_tt.cpp
Modified: trunk/matplotlib/CXX/WrapPython.h
===================================================================
--- trunk/matplotlib/CXX/WrapPython.h 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/CXX/WrapPython.h 2008-04-24 13:23:05 UTC (rev 5071)
@@ -38,12 +38,13 @@
#ifndef __PyCXX_wrap_python_hxx__
#define __PyCXX_wrap_python_hxx__
+// pull in python definitions
+#include <Python.h>
+
// On some platforms we have to include time.h to get select defined
#if !defined(__WIN32__) && !defined(WIN32) && !defined(_WIN32) && !defined(_WIN64)
#include <sys/time.h>
#endif
-// pull in python definitions
-#include <Python.h>
#endif
Modified: trunk/matplotlib/agg24/src/agg_curves.cpp
===================================================================
--- trunk/matplotlib/agg24/src/agg_curves.cpp 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/agg24/src/agg_curves.cpp 2008-04-24 13:23:05 UTC (rev 5071)
@@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
-// Permission to copy, use, modify, sell and distribute this software
-// is granted provided this copyright notice appears in all copies.
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@@ -29,20 +29,20 @@
//------------------------------------------------------------------------
- void curve3_inc::approximation_scale(double s)
- {
+ void curve3_inc::approximation_scale(double s)
+ {
m_scale = s;
}
//------------------------------------------------------------------------
- double curve3_inc::approximation_scale() const
- {
+ double curve3_inc::approximation_scale() const
+ {
return m_scale;
}
//------------------------------------------------------------------------
- void curve3_inc::init(double x1, double y1,
- double x2, double y2,
+ void curve3_inc::init(double x1, double y1,
+ double x2, double y2,
double x3, double y3)
{
m_start_x = x1;
@@ -55,13 +55,13 @@
double dx2 = x3 - x2;
double dy2 = y3 - y2;
- double len = sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * dy2);
+ double len = sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * dy2);
m_num_steps = uround(len * 0.25 * m_scale);
if(m_num_steps < 4)
{
- m_num_steps = 4;
+ m_num_steps = 4;
}
double subdivide_step = 1.0 / m_num_steps;
@@ -72,7 +72,7 @@
m_saved_fx = m_fx = x1;
m_saved_fy = m_fy = y1;
-
+
m_saved_dfx = m_dfx = tmpx + (x2 - x1) * (2.0 * subdivide_step);
m_saved_dfy = m_dfy = tmpy + (y2 - y1) * (2.0 * subdivide_step);
@@ -115,10 +115,10 @@
--m_step;
return path_cmd_line_to;
}
- m_fx += m_dfx;
+ m_fx += m_dfx;
m_fy += m_dfy;
- m_dfx += m_ddfx;
- m_dfy += m_ddfy;
+ m_dfx += m_ddfx;
+ m_dfy += m_ddfy;
*x = m_fx;
*y = m_fy;
--m_step;
@@ -126,8 +126,8 @@
}
//------------------------------------------------------------------------
- void curve3_div::init(double x1, double y1,
- double x2, double y2,
+ void curve3_div::init(double x1, double y1,
+ double x2, double y2,
double x3, double y3)
{
m_points.remove_all();
@@ -138,19 +138,19 @@
}
//------------------------------------------------------------------------
- void curve3_div::recursive_bezier(double x1, double y1,
- double x2, double y2,
+ void curve3_div::recursive_bezier(double x1, double y1,
+ double x2, double y2,
double x3, double y3,
unsigned level)
{
- if(level > curve_recursion_limit)
+ if(level > curve_recursion_limit)
{
return;
}
// Calculate all the mid-points of the line segments
//----------------------
- double x12 = (x1 + x2) / 2;
+ double x12 = (x1 + x2) / 2;
double y12 = (y1 + y2) / 2;
double x23 = (x2 + x3) / 2;
double y23 = (y2 + y3) / 2;
@@ -163,7 +163,7 @@
double da;
if(d > curve_collinearity_epsilon)
- {
+ {
// Regular case
//-----------------
if(d * d <= m_distance_tolerance_square * (dx*dx + dy*dy))
@@ -187,7 +187,7 @@
// Finally we can stop the recursion
//----------------------
m_points.add(point_d(x123, y123));
- return;
+ return;
}
}
}
@@ -222,13 +222,13 @@
// Continue subdivision
//----------------------
- recursive_bezier(x1, y1, x12, y12, x123, y123, level + 1);
- recursive_bezier(x123, y123, x23, y23, x3, y3, level + 1);
+ recursive_bezier(x1, y1, x12, y12, x123, y123, level + 1);
+ recursive_bezier(x123, y123, x23, y23, x3, y3, level + 1);
}
//------------------------------------------------------------------------
- void curve3_div::bezier(double x1, double y1,
- double x2, double y2,
+ void curve3_div::bezier(double x1, double y1,
+ double x2, double y2,
double x3, double y3)
{
m_points.add(point_d(x1, y1));
@@ -241,23 +241,25 @@
//------------------------------------------------------------------------
- void curve4_inc::approximation_scale(double s)
- {
+ void curve4_inc::approximation_scale(double s)
+ {
m_scale = s;
}
//------------------------------------------------------------------------
- double curve4_inc::approximation_scale() const
- {
+ double curve4_inc::approximation_scale() const
+ {
return m_scale;
}
//------------------------------------------------------------------------
+#if defined(_MSC_VER) && _MSC_VER <= 1200
static double MSC60_fix_ICE(double v) { return v; }
+#endif
//------------------------------------------------------------------------
- void curve4_inc::init(double x1, double y1,
- double x2, double y2,
+ void curve4_inc::init(double x1, double y1,
+ double x2, double y2,
double x3, double y3,
double x4, double y4)
{
@@ -273,8 +275,8 @@
double dx3 = x4 - x3;
double dy3 = y4 - y3;
- double len = (sqrt(dx1 * dx1 + dy1 * dy1) +
- sqrt(dx2 * dx2 + dy2 * dy2) +
+ double len = (sqrt(dx1 * dx1 + dy1 * dy1) +
+ sqrt(dx2 * dx2 + dy2 * dy2) +
sqrt(dx3 * dx3 + dy3 * dy3)) * 0.25 * m_scale;
#if defined(_MSC_VER) && _MSC_VER <= 1200
@@ -285,7 +287,7 @@
if(m_num_steps < 4)
{
- m_num_steps = 4;
+ m_num_steps = 4;
}
double subdivide_step = 1.0 / m_num_steps;
@@ -296,7 +298,7 @@
double pre2 = 3.0 * subdivide_step2;
double pre4 = 6.0 * subdivide_step2;
double pre5 = 6.0 * subdivide_step3;
-
+
double tmp1x = x1 - x2 * 2.0 + x3;
double tmp1y = y1 - y2 * 2.0 + y3;
@@ -357,10 +359,10 @@
m_fx += m_dfx;
m_fy += m_dfy;
- m_dfx += m_ddfx;
- m_dfy += m_ddfy;
- m_ddfx += m_dddfx;
- m_ddfy += m_dddfy;
+ m_dfx += m_ddfx;
+ m_dfy += m_ddfy;
+ m_ddfx += m_dddfx;
+ m_ddfy += m_dddfy;
*x = m_fx;
*y = m_fy;
@@ -372,8 +374,8 @@
//------------------------------------------------------------------------
- void curve4_div::init(double x1, double y1,
- double x2, double y2,
+ void curve4_div::init(double x1, double y1,
+ double x2, double y2,
double x3, double y3,
double x4, double y4)
{
@@ -385,13 +387,13 @@
}
//------------------------------------------------------------------------
- void curve4_div::recursive_bezier(double x1, double y1,
- double x2, double y2,
- double x3, double y3,
+ void curve4_div::recursive_bezier(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
double x4, double y4,
unsigned level)
{
- if(level > curve_recursion_limit)
+ if(level > curve_recursion_limit)
{
return;
}
@@ -542,7 +544,7 @@
}
break;
- case 3:
+ case 3:
// Regular case
//-----------------
if((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + dy*dy))
@@ -592,14 +594,14 @@
// Continue subdivision
//----------------------
- recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1);
- recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1);
+ recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1);
+ recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1);
}
//------------------------------------------------------------------------
- void curve4_div::bezier(double x1, double y1,
- double x2, double y2,
- double x3, double y3,
+ void curve4_div::bezier(double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
double x4, double y4)
{
m_points.add(point_d(x1, y1));
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,12 +1,22 @@
/* A rewrite of _backend_agg using PyCXX to handle ref counting, etc..
*/
+#include <png.h>
+// To remove a gcc warning
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
+#include "ft2font.h"
+#include "_image.h"
+#include "_backend_agg.h"
+#include "mplutils.h"
+
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <stdexcept>
-#include <png.h>
#include <time.h>
#include <algorithm>
@@ -23,11 +33,6 @@
#include "agg_conv_shorten_path.h"
#include "util/agg_color_conv_rgb8.h"
-#include "ft2font.h"
-#include "_image.h"
-#include "_backend_agg.h"
-#include "mplutils.h"
-
#include "swig_runtime.h"
#include "MPL_isnan.h"
@@ -295,8 +300,8 @@
SnapData
SafeSnap::snap (const float& x, const float& y) {
- xsnap = (int)x + 0.5;
- ysnap = (int)y + 0.5;
+ xsnap = (int)(x + 0.5f);
+ ysnap = (int)(y + 0.5f);
if ( first || ( (xsnap!=lastxsnap) || (ysnap!=lastysnap) ) ) {
lastxsnap = xsnap;
@@ -737,8 +742,8 @@
args.verify_length(4, 6);
- float x = Py::Float(args[0]);
- float y = Py::Float(args[1]);
+ double x = Py::Float(args[0]);
+ double y = Py::Float(args[1]);
Image *image = static_cast<Image*>(args[2].ptr());
Py::Object box_obj = args[3];
Py::Object clippath;
Modified: trunk/matplotlib/src/_gtkagg.cpp
===================================================================
--- trunk/matplotlib/src/_gtkagg.cpp 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_gtkagg.cpp 2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,3 +1,6 @@
+#include <pygobject.h>
+#include <pygtk/pygtk.h>
+
#include <cstring>
#include <cerrno>
#include <cstdio>
@@ -6,10 +9,6 @@
#include <utility>
#include <fstream>
-
-#include <pygobject.h>
-#include <pygtk/pygtk.h>
-
#include "agg_basics.h"
#include "_backend_agg.h"
#define PY_ARRAY_TYPES_PREFIX NumPy
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_image.cpp 2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,3 +1,6 @@
+#include "Python.h" //after png.h due to setjmp bug
+#include <string>
+
#include <iostream>
#include <fstream>
#include <cmath>
@@ -4,9 +7,6 @@
#include <cstdio>
#include <png.h>
-#include "Python.h" //after png.h due to setjmp bug
-#include <string>
-
#define PY_ARRAY_TYPES_PREFIX NumPy
#include "numpy/arrayobject.h"
@@ -936,10 +936,10 @@
png_byte* ptr = (rgba) ? &(row[x*4]) : &(row[x*3]);
size_t offset = y*A->strides[0] + x*A->strides[1];
//if ((y<10)&&(x==10)) std::cout << "r = " << ptr[0] << " " << ptr[0]/255.0 << std::endl;
- *(float*)(A->data + offset + 0*A->strides[2]) = ptr[0]/255.0;
- *(float*)(A->data + offset + 1*A->strides[2]) = ptr[1]/255.0;
- *(float*)(A->data + offset + 2*A->strides[2]) = ptr[2]/255.0;
- *(float*)(A->data + offset + 3*A->strides[2]) = rgba ? ptr[3]/255.0 : 1.0;
+ *(float*)(A->data + offset + 0*A->strides[2]) = (float)(ptr[0]/255.0f);
+ *(float*)(A->data + offset + 1*A->strides[2]) = (float)(ptr[1]/255.0f);
+ *(float*)(A->data + offset + 2*A->strides[2]) = (float)(ptr[2]/255.0f);
+ *(float*)(A->data + offset + 3*A->strides[2]) = rgba ? (float)(ptr[3]/255.0f) : 1.0f;
}
}
@@ -1434,7 +1434,7 @@
while(xs2 != xl && xo > xm) {
xs1 = xs2;
xs2 = xs1+1;
- xm = 0.5*(*xs1 + *xs2);
+ xm = 0.5f*(*xs1 + *xs2);
j++;
}
*colstart = j - j_last;
@@ -1447,7 +1447,7 @@
while(ys2 != yl && yo > ym) {
ys1 = ys2;
ys2 = ys1+1;
- ym = 0.5*(*ys1 + *ys2);
+ ym = 0.5f*(*ys1 + *ys2);
j++;
}
*rowstart = j - j_last;
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_path.cpp 2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,9 +1,9 @@
+#include "agg_py_path_iterator.h"
+#include "agg_py_transforms.h"
+
#include <limits>
#include <math.h>
-#include "agg_py_path_iterator.h"
-#include "agg_py_transforms.h"
-
#include "CXX/Extensions.hxx"
#include "agg_conv_curve.h"
Modified: trunk/matplotlib/src/_ttconv.cpp
===================================================================
--- trunk/matplotlib/src/_ttconv.cpp 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_ttconv.cpp 2008-04-24 13:23:05 UTC (rev 5071)
@@ -83,11 +83,11 @@
int fonttype;
std::vector<int> glyph_ids;
- static const char *kwlist[] = {
+ static const char *kwlist[] = {
"filename", "output", "fonttype", "glyph_ids", NULL };
if (! PyArg_ParseTupleAndKeywords
- (args, kwds,
- "sO&i|O&:convert_ttf_to_ps",
+ (args, kwds,
+ "sO&i|O&:convert_ttf_to_ps",
(char**)kwlist,
&filename,
fileobject_to_PythonFileWriter,
@@ -96,9 +96,9 @@
pyiterable_to_vector_int,
&glyph_ids))
return NULL;
-
+
if (fonttype != 3 && fonttype != 42) {
- PyErr_SetString(PyExc_ValueError,
+ PyErr_SetString(PyExc_ValueError,
"fonttype must be either 3 (raw Postscript) or 42 "
"(embedded Truetype)");
return NULL;
@@ -109,7 +109,7 @@
} catch (TTException& e) {
PyErr_SetString(PyExc_RuntimeError, e.getMessage());
return NULL;
- } catch (PythonExceptionOccurred& e) {
+ } catch (PythonExceptionOccurred& ) {
return NULL;
} catch (...) {
PyErr_SetString(PyExc_RuntimeError, "Unknown C++ exception");
@@ -144,8 +144,8 @@
static const char *kwlist[] = { "filename", "glyph_ids", NULL };
if (! PyArg_ParseTupleAndKeywords
- (args, kwds,
- "s|O&:convert_ttf_to_ps",
+ (args, kwds,
+ "s|O&:convert_ttf_to_ps",
(char **)kwlist,
&filename,
pyiterable_to_vector_int,
@@ -163,7 +163,7 @@
} catch (TTException& e) {
PyErr_SetString(PyExc_RuntimeError, e.getMessage());
return NULL;
- } catch (PythonExceptionOccurred& e) {
+ } catch (PythonExceptionOccurred& ) {
return NULL;
} catch (...) {
PyErr_SetString(PyExc_RuntimeError, "Unknown C++ exception");
@@ -174,7 +174,7 @@
}
static PyMethodDef ttconv_methods[] = {
- {"convert_ttf_to_ps", (PyCFunction)convert_ttf_to_ps, METH_KEYWORDS,
+ {"convert_ttf_to_ps", (PyCFunction)convert_ttf_to_ps, METH_KEYWORDS,
"convert_ttf_to_ps(filename, output, fonttype, glyph_ids)\n"
"\n"
"Converts the Truetype font into a Type 3 or Type 42 Postscript font, "
@@ -191,7 +191,7 @@
"then all glyphs will be included. If any of the glyphs specified are "
"composite glyphs, then the component glyphs will also be included."
},
- {"get_pdf_charprocs", (PyCFunction)py_get_pdf_charprocs, METH_KEYWORDS,
+ {"get_pdf_charprocs", (PyCFunction)py_get_pdf_charprocs, METH_KEYWORDS,
"get_pdf_charprocs(filename, glyph_ids)\n"
"\n"
"Given a Truetype font file, returns a dictionary containing the PDF Type 3\n"
@@ -211,7 +211,7 @@
#define PyMODINIT_FUNC void
#endif
PyMODINIT_FUNC
-initttconv(void)
+initttconv(void)
{
PyObject* m;
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/ft2font.cpp 2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,6 +1,6 @@
-#include <sstream>
#include "ft2font.h"
#include "mplutils.h"
+#include <sstream>
#define FIXED_MAJOR(val) (*((short *) &val+1))
#define FIXED_MINOR(val) (*((short *) &val+0))
Modified: trunk/matplotlib/src/ft2font.h
===================================================================
--- trunk/matplotlib/src/ft2font.h 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/ft2font.h 2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,6 +1,8 @@
/* A python interface to freetype2 */
#ifndef _FT2FONT_H
#define _FT2FONT_H
+#include "CXX/Extensions.hxx"
+#include "CXX/Objects.hxx"
#include <iostream>
#include <vector>
#include <string>
@@ -15,8 +17,6 @@
#include FT_TYPE1_TABLES_H
#include FT_TRUETYPE_TABLES_H
}
-#include "CXX/Extensions.hxx"
-#include "CXX/Objects.hxx"
// the freetype string rendered into a width, height buffer
Modified: trunk/matplotlib/ttconv/pprdrv_tt.cpp
===================================================================
--- trunk/matplotlib/ttconv/pprdrv_tt.cpp 2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/ttconv/pprdrv_tt.cpp 2008-04-24 13:23:05 UTC (rev 5071)
@@ -16,7 +16,7 @@
** documentation. This software is provided "as is" without express or
** implied warranty.
**
-** TrueType font support. These functions allow PPR to generate
+** TrueType font support. These functions allow PPR to generate
** PostScript fonts from Microsoft compatible TrueType font files.
**
** Last revised 19 December 1995.
@@ -31,7 +31,7 @@
#include <sstream>
/*==========================================================================
-** Convert the indicated Truetype font file to a type 42 or type 3
+** Convert the indicated Truetype font file to a type 42 or type 3
** PostScript font and insert it in the output stream.
**
** All the routines from here to the end of file file are involved
@@ -42,7 +42,7 @@
** Endian conversion routines.
** These routines take a BYTE pointer
** and return a value formed by reading
-** bytes starting at that point.
+** bytes starting at that point.
**
** These routines read the big-endian
** values which are used in TrueType
@@ -55,14 +55,14 @@
ULONG getULONG(BYTE *p)
{
int x;
- ULONG val=0;
+ ULONG val=0;
for(x=0; x<4; x++)
{
val *= 0x100;
- val += p[x];
+ val += p[x];
}
-
+
return val;
} /* end of ftohULONG() */
@@ -72,14 +72,14 @@
USHORT getUSHORT(BYTE *p)
{
int x;
- USHORT val=0;
+ USHORT val=0;
for(x=0; x<2; x++)
{
val *= 0x100;
- val += p[x];
+ val += p[x];
}
-
+
return val;
} /* end of getUSHORT() */
@@ -92,7 +92,7 @@
Fixed val={0,0};
val.whole = ((s[0] * 256) + s[1]);
- val.fraction = ((s[2] * 256) + s[3]);
+ val.fraction = ((s[2] * 256) + s[3]);
return val;
} /* end of getFixed() */
@@ -102,16 +102,16 @@
** The font's "file" and "offset_table" fields must be set before this
** routine is called.
**
-** This first argument is a TrueType font structure, the second
+** This first argument is a TrueType font structure, the second
** argument is the name of the table to retrieve. A table name
-** is always 4 characters, though the last characters may be
+** is always 4 characters, though the last characters may be
** padding spaces.
-----------------------------------------------------------------------*/
BYTE *GetTable(struct TTFONT *font, const char *name)
{
BYTE *ptr;
ULONG x;
-
+
#ifdef DEBUG_TRUETYPE
debug("GetTable(file,font,\"%s\")",name);
#endif
@@ -127,20 +127,20 @@
BYTE *table;
offset = getULONG( ptr + 8 );
- length = getULONG( ptr + 12 );
+ length = getULONG( ptr + 12 );
table = (BYTE*)calloc( sizeof(BYTE), length );
try {
#ifdef DEBUG_TRUETYPE
debug("Loading table \"%s\" from offset %d, %d bytes",name,offset,length);
#endif
-
+
if( fseek( font->file, (long)offset, SEEK_SET ) )
throw TTException("TrueType font may be corrupt (reason 3)");
-
+
if( fread(table,sizeof(BYTE),length,font->file) != (sizeof(BYTE) * length))
throw TTException("TrueType font may be corrupt (reason 4)");
- } catch (TTException& e) {
+ } catch (TTException& ) {
free(table);
throw;
}
@@ -156,7 +156,7 @@
} /* end of GetTable() */
/*--------------------------------------------------------------------
-** Load the 'name' table, get information from it,
+** Load the 'name' table, get information from it,
** and store that information in the font structure.
**
** The 'name' table contains information such as the name of
@@ -171,7 +171,7 @@
int platform,encoding; /* Current platform id, encoding id, */
int language,nameid; /* language id, name id, */
int offset,length; /* offset and length of string. */
-
+
#ifdef DEBUG_TRUETYPE
debug("Read_name()");
#endif
@@ -188,7 +188,7 @@
try {
numrecords = getUSHORT( table_ptr + 2 ); /* number of names */
strings = table_ptr + getUSHORT( table_ptr + 4 ); /* start of string storage */
-
+
ptr2 = table_ptr + 6;
for(x=0; x < numrecords; x++,ptr2+=12)
{
@@ -202,7 +202,7 @@
#ifdef DEBUG_TRUETYPE
debug("platform %d, encoding %d, language 0x%x, name %d, offset %d, length %d",
platform,encoding,language,nameid,offset,length);
-#endif
+#endif
/* Copyright notice */
if( platform == 1 && nameid == 0 )
@@ -211,14 +211,14 @@
strncpy(font->Copyright,(const char*)strings+offset,length);
font->Copyright[length]=(char)NULL;
replace_newlines_with_spaces(font->Copyright);
-
+
#ifdef DEBUG_TRUETYPE
debug("font->Copyright=\"%s\"",font->Copyright);
#endif
continue;
}
-
+
/* Font Family name */
if( platform == 1 && nameid == 1 )
{
@@ -226,7 +226,7 @@
strncpy(font->FamilyName,(const char*)strings+offset,length);
font->FamilyName[length]=(char)NULL;
replace_newlines_with_spaces(font->FamilyName);
-
+
#ifdef DEBUG_TRUETYPE
debug("font->FamilyName=\"%s\"",font->FamilyName);
#endif
@@ -241,14 +241,14 @@
strncpy(font->Style,(const char*)strings+offset,length);
font->Style[length]=(char)NULL;
replace_newlines_with_spaces(font->Style);
-
+
#ifdef DEBUG_TRUETYPE
debug("font->Style=\"%s\"",font->Style);
#endif
continue;
}
-
-
+
+
/* Full Font name */
if( platform == 1 && nameid == 4 )
{
@@ -256,14 +256,14 @@
strncpy(font->FullName,(const char*)strings+offset,length);
font->FullName[length]=(char)NULL;
replace_newlines_with_spaces(font->FullName);
-
+
#ifdef DEBUG_TRUETYPE
debug("font->FullName=\"%s\"",font->FullName);
#endif
continue;
}
-
-
+
+
/* Version string */
if( platform == 1 && nameid == 5 )
{
@@ -277,8 +277,8 @@
#endif
continue;
}
-
-
+
+
/* PostScript name */
if( platform == 1 && nameid == 6 )
{
@@ -292,8 +292,8 @@
#endif
continue;
}
-
-
+
+
/* Trademark string */
if( platform == 1 && nameid == 7 )
{
@@ -301,15 +301,15 @@
strncpy(font->Trademark,(const char*)strings+offset,length);
font->Trademark[length]=(char)NULL;
replace_newlines_with_spaces(font->Trademark);
-
+
#ifdef DEBUG_TRUETYPE
debug("font->Trademark=\"%s\"",font->Trademark);
#endif
continue;
}
-
+
}
- } catch (TTException& e) {
+ } catch (TTException& ) {
free(table_ptr);
throw;
}
@@ -443,20 +443,20 @@
/* Some information from the "post" table. */
ItalicAngle = getFixed( font->post_table + 4 );
stream.printf("/ItalicAngle %d.%d def\n",ItalicAngle.whole,ItalicAngle.fraction);
- stream.printf("/isFixedPitch %s def\n", getULONG( font->post_table + 12 ) ? "true" : "false" );
+ stream.printf("/isFixedPitch %s def\n", getULONG( font->post_table + 12 ) ? "true" : "false" );
stream.printf("/UnderlinePosition %d def\n", (int)getFWord( font->post_table + 8 ) );
- stream.printf("/UnderlineThickness %d def\n", (int)getFWord( font->post_table + 10 ) );
- stream.putline("end readonly def");
- } /* end of ttfont_FontInfo() */
+ stream.printf("/UnderlineThickness %d def\n", (int)getFWord( font->post_table + 10 ) );
+ stream.putline("end readonly def");
+ } /* end of ttfont_FontInfo() */
/*-------------------------------------------------------------------
** sfnts routines
-** These routines generate the PostScript "sfnts" array which
+** These routines generate the PostScript "sfnts" array which
** contains one or more strings which contain a reduced version
** of the TrueType font.
**
** A number of functions are required to accomplish this rather
-** complicated task.
+** complicated task.
-------------------------------------------------------------------*/
int string_len;
int line_len;
@@ -498,9 +498,9 @@
stream.putchar('\n');
line_len=0;
}
-
+
} /* end of sfnts_pputBYTE() */
-
+
/*
** Write a USHORT as a hexadecimal value as part of the sfnts array.
*/
@@ -516,7 +516,7 @@
void sfnts_pputULONG(TTStreamWriter& stream, ULONG n)
{
int x1,x2,x3;
-
+
x1 = n % 256;
n /= 256;
x2 = n % 256;
@@ -531,7 +531,7 @@
} /* end of sfnts_pputULONG() */
/*
-** This is called whenever it is
+** This is called whenever it is
** necessary to end a string in the sfnts array.
**
** (The array must be broken into strings which are
@@ -542,7 +542,7 @@
if(in_string)
{
string_len=0; /* fool sfnts_pputBYTE() */
-
+
#ifdef DEBUG_TRUETYPE_INLINE
puts("\n% dummy byte:\n");
#endif
@@ -562,7 +562,7 @@
*/
void sfnts_new_table(TTStreamWriter& stream, ULONG length)
{
- if( (string_len + length) > 65528 )
+ if( (string_len + length) > 65528 )
sfnts_end_string(stream);
} /* end of sfnts_new_table() */
@@ -615,7 +615,7 @@
/* Start new string if necessary. */
sfnts_new_table( stream, (int)length );
- /*
+ /*
** Make sure the glyph is padded out to a
** two byte boundary.
*/
@@ -627,16 +627,16 @@
{
if( (c = fgetc(font->file)) == EOF )
throw TTException("TrueType font may be corrupt (reason 6)");
-
+
sfnts_pputBYTE(stream, c);
total++; /* add to running total */
- }
+ }
}
free(font->loca_table);
font->loca_table = NULL;
-
+
/* Pad out to full length from table directory */
while( total < correct_total_length )
{
@@ -649,7 +649,7 @@
/*
** Here is the routine which ties it all together.
**
-** Create the array called "sfnts" which
+** Create the array called "sfnts" which
** holds the actual TrueType data.
*/
void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)
@@ -673,7 +673,7 @@
ULONG length;
ULONG checksum;
} tables[9];
-
+
BYTE *ptr; /* A pointer into the origional table directory. */
ULONG x,y; /* General use loop countes. */
int c; /* Input character. */
@@ -684,8 +684,8 @@
ptr = font->offset_table + 12;
nextoffset=0;
count=0;
-
- /*
+
+ /*
** Find the tables we want and store there vital
** statistics in tables[].
*/
@@ -697,7 +697,7 @@
if( diff > 0 ) /* If we are past it. */
{
tables[x].length = 0;
- diff = 0;
+ diff = 0;
}
else if( diff < 0 ) /* If we haven't hit it yet. */
{
@@ -711,12 +711,12 @@
tables[x].length = getULONG( ptr + 12 );
nextoffset += ( ((tables[x].length + 3) / 4) * 4 );
count++;
- ptr += 16;
+ ptr += 16;
}
} while(diff != 0);
-
+
} /* end of for loop which passes over the table directory */
-
+
/* Begin the sfnts array. */
sfnts_start(stream);
@@ -724,10 +724,10 @@
/* Start by copying the TrueType version number. */
ptr = font->offset_table;
for(x=0; x < 4; x++)
- {
+ {
sfnts_pputBYTE( stream, *(ptr++) );
}
-
+
/* Now, generate those silly numTables numbers. */
sfnts_pputUSHORT(stream, count); /* number of tables */
if( count == 9 )
@@ -735,11 +735,11 @@
sfnts_pputUSHORT(stream, 7); /* searchRange */
sfnts_pputUSHORT(stream, 3); /* entrySelector */
sfnts_pputUSHORT(stream, 81); /* rangeShift */
- }
+ }
#ifdef DEBUG_TRUETYPE
else
{
- debug("only %d tables selected",count);
+ debug("only %d tables selected",count);
}
#endif
@@ -754,13 +754,13 @@
sfnts_pputBYTE( stream, table_names[x][1] );
sfnts_pputBYTE( stream, table_names[x][2] );
sfnts_pputBYTE( stream, table_names[x][3] );
-
+
/* Checksum */
sfnts_pputULONG( stream, tables[x].checksum );
/* Offset */
sfnts_pputULONG( stream, tables[x].newoffset + 12 + (count * 16) );
-
+
/* Length */
sfnts_pputULONG( stream, tables[x].length );
}
@@ -770,7 +770,7 @@
{
if( tables[x].length == 0 ) /* skip tables that aren't there */
continue;
-
+
#ifdef DEBUG_TRUETYPE
debug("emmiting table '%s'",table_names[x]);
#endif
@@ -783,22 +783,22 @@
else /* Other tables may not exceed */
{ /* 65535 bytes in length. */
if( tables[x].length > 65535 )
- throw TTException("TrueType font has a table which is too long");
-
+ throw TTException("TrueType font has a table which is too long");
+
/* Start new string if necessary. */
sfnts_new_table(stream, tables[x].length);
/* Seek to proper position in the file. */
fseek( font->file, tables[x].oldoffset, SEEK_SET );
-
+
/* Copy the bytes of the table. */
for( y=0; y < tables[x].length; y++ )
{
if( (c = fgetc(font->file)) == EOF )
throw TTException("TrueType font may be corrupt (reason 7)");
-
+
sfnts_pputBYTE(stream, c);
- }
+ }
}
/* Padd it out to a four byte boundary. */
@@ -815,39 +815,39 @@
} /* End of loop for all tables */
/* Close the array. */
- sfnts_end_string(stream);
+ sfnts_end_string(stream);
stream.putline("]def");
} /* end of ttfont_sfnts() */
-
-/*--------------------------------------------------------------
-** Create the CharStrings dictionary which will translate
-** PostScript character names to TrueType font character
+
+/*--------------------------------------------------------------
+** Create the CharStrings dictionary which will translate
+** PostScript character names to TrueType font character
** indexes.
**
** If we are creating a type 3 instead of a type 42 font,
** this array will instead convert PostScript character names
** to executable proceedures.
--------------------------------------------------------------*/
-const char *Apple_CharStrings[]={
-".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign",
-"dollar","percent","ampersand","quotesingle","parenleft","parenright",
+const char *Apple_CharStrings[]={
+".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign",
+"dollar","percent","ampersand","quotesingle","parenleft","parenright",
"asterisk","plus", "comma","hyphen","period","slash","zero","one","two",
-"three","four","five","six","seven","eight","nine","colon","semicolon",
+"three","four","five","six","seven","eight","nine","colon","semicolon",
"less","equal","greater","question","at","A","B","C","D","E","F","G","H","I",
"J","K", "L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
"bracketleft","backslash","bracketright","asciicircum","underscore","grave",
-"a","b","c","d","e","f","g","h","i","j","k", "l","m","n","o","p","q","r","s",
+"a","b","c","d","e","f","g","h","i","j","k", "l","m","n","o","p","q","r","s",
"t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde",
"Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis",
"aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla",
-"eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex",
+"eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex",
"idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde",
"uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent",
"sterling","section","bullet","paragraph","germandbls","registered",
"copyright","trademark","acute","dieresis","notequal","AE","Oslash",
"infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff",
"summation","product","pi","integral","ordfeminine","ordmasculine","Omega",
-"ae","oslash","questiondown","exclamdown","logicalnot","radical","florin",
+"ae","oslash","questiondown","exclamdown","logicalnot","radical","florin",
"approxequal","Delta","guillemotleft","guillemotright","ellipsis",
"nobreakspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash",
"quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge",
@@ -861,7 +861,7 @@
"Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior",
"twosuperior","threesuperior","onehalf","onequarter","threequarters","franc",
"Gbreve","gbreve","Idot","Scedilla","scedilla","Cacute","cacute","Ccaron",
-"ccaron","dmacron","markingspace","capslock","shift","propeller","enter",
+"ccaron","dmacron","markingspace","capslock","shift","propeller","enter",
"markingtabrtol","markingtabltor","control","markingdeleteltor",
"markingdeletertol","option","escape","parbreakltor","parbreakrtol",
"newpage","checkmark","linebreakltor","linebreakrtol","markingnobreakspace",
@@ -879,7 +879,7 @@
ULONG len;
GlyphIndex = (int)getUSHORT( font->post_table + 34 + (charindex * 2) );
-
+
if( GlyphIndex <= 257 ) /* If a standard Apple name, */
{
return Apple_CharStrings[GlyphIndex];
@@ -887,7 +887,7 @@
else /* Otherwise, use one */
{ /* of the pascal strings. */
GlyphIndex -= 258;
-
+
/* Set pointer to start of Pascal strings. */
ptr = (char*)(font->post_table + 34 + (font->numGlyphs * 2));
@@ -897,7 +897,7 @@
ptr += len;
len = (ULONG)*(ptr++);
}
-
+
if( len >= sizeof(temp) )
throw TTException("TrueType font file contains a very long PostScript name");
@@ -914,16 +914,16 @@
void ttfont_CharStrings(TTStreamWriter& stream, struct TTFONT *font, std::vector<int>& glyph_ids)
{
Fixed post_format;
-
+
/* The 'post' table format number. */
post_format = getFixed( font->post_table );
-
+
if( post_format.whole != 2 || post_format.fraction != 0 )
throw TTException("TrueType fontdoes not have a format 2.0 'post' table");
/* Emmit the start of the PostScript code to define the dictionary. */
stream.printf("/CharStrings %d dict dup begin\n", glyph_ids.size());
-
+
/* Emmit one key-value pair for each glyph. */
for(std::vector<int>::const_iterator i = glyph_ids.begin();
i != glyph_ids.end(); ++i)
@@ -935,13 +935,13 @@
else /* type 3 */
{
stream.printf("/%s{",ttfont_CharStrings_getname(font, *i));
-
+
tt_type3_charproc(stream, font, *i);
-
+
stream.putline("}_d"); /* "} bind def" */
}
}
-
+
stream.putline("end readonly def");
} /* end of ttfont_CharStrings() */
@@ -971,8 +971,8 @@
stream.putline("/BuildChar {");
stream.putline(" 1 index /Encoding get exch get");
stream.putline(" 1 index /BuildGlyph get exec");
- stream.putline("}_d");
-
+ stream.putline("}_d");
+
stream.putchar('\n');
}
@@ -999,7 +999,7 @@
stream.putline("{/TrueDict where{pop}{(%%[ Error: no TrueType rasterizer ]%%)= flush}ifelse");
/* Since we are expected to use Apple's TrueDict TrueType */
- /* reasterizer, change the font type to 3. */
+ /* reasterizer, change the font type to 3. */
stream.putline("/FontType 3 def");
/* Define a string to hold the state of the Apple */
@@ -1035,7 +1035,7 @@
/* Exchange the CharStrings dictionary and the charname, */
/* but if the answer was false, replace the character name */
- /* with ".notdef". */
+ /* with ".notdef". */
stream.putline(" {exch}{exch pop /.notdef}ifelse");
/* stack: CharStrings charname */
@@ -1060,7 +1060,7 @@
stream.putline(" /BuildChar{");
stream.putline(" 1 index /Encoding get exch get");
stream.putline(" 1 index /BuildGlyph get exec");
- stream.putline(" }bind def");
+ stream.putline(" }bind def");
/* Here we close the condition which is true */
/* if the printer has no built-in TrueType */
@@ -1071,7 +1071,7 @@
stream.putline("FontName currentdict end definefont pop");
stream.putline("%%EOF");
- } /* end of ttfont_trailer() */
+ } /* end of ttfont_trailer() */
/*------------------------------------------------------------------
** This is the externally callable routine which inserts the font.
@@ -1080,7 +1080,7 @@
void read_font(const char *filename, font_type_enum target_type, std::vector<int>& glyph_ids, TTFONT& font)
{
BYTE *ptr;
-
+
/* Decide what type of PostScript font we will be generating. */
font.target_type = target_type;
@@ -1094,24 +1094,24 @@
/* Allocate space for the unvarying part of the offset table. */
assert(font.offset_table == NULL);
font.offset_table = (BYTE*)calloc( 12, sizeof(BYTE) );
-
+
/* Read the first part of the offset table. */
if( fread( font.offset_table, sizeof(BYTE), 12, font.file ) != 12 )
throw TTException("TrueType font may be corrupt (reason 1)");
-
+
/* Determine how many directory entries there are. */
font.numTables = getUSHORT( font.offset_table + 4 );
#ifdef DEBUG_TRUETYPE
debug("numTables=%d",(int)font.numTables);
#endif
-
+
/* Expand the memory block to hold the whole thing. */
font.offset_table = (BYTE*)realloc( font.offset_table, sizeof(BYTE) * (12 + font.numTables * 16) );
-
+
/* Read the rest of the table directory. */
if( fread( font.offset_table + 12, sizeof(BYTE), (font.numTables*16), font.file ) != (font.numTables*16) )
throw TTException("TrueType font may be corrupt (reason 2)");
-
+
/* Extract information from the "Offset" table. */
font.TTVersion = getFixed( font.offset_table );
@@ -1133,7 +1133,7 @@
throw TTException("TrueType font is unusable because indexToLocFormat != 0");
if( getSHORT(ptr+52) != 0 )
throw TTException("TrueType font is unusable because glyphDataFormat != 0");
- } catch (TTException& e) {
+ } catch (TTException& ) {
free(ptr);
throw;
}
@@ -1177,7 +1177,7 @@
} /* end of insert_ttfont() */
-void insert_ttfont(const char *filename, TTStreamWriter& stream,
+void insert_ttfont(const char *filename, TTStreamWriter& stream,
font_type_enum target_type, std::vector<int>& glyph_ids)
{
struct TTFONT font;
@@ -1233,9 +1233,9 @@
}
TTFONT::TTFONT() :
- file(NULL),
+ file(NULL),
PostName(NULL),
- FullName(NULL),
+ FullName(NULL),
FamilyName(NULL),
Style(NULL),
Copyright(NULL),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-24 12:54:30
|
Revision: 5070
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5070&view=rev
Author: mdboom
Date: 2008-04-24 05:54:25 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Fix compilation issues on VS2003. (Thanks Martin Spacek)
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/agg_py_path_iterator.h
trunk/matplotlib/src/mplutils.h
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-24 12:34:47 UTC (rev 5069)
+++ trunk/matplotlib/CHANGELOG 2008-04-24 12:54:25 UTC (rev 5070)
@@ -1,3 +1,6 @@
+2008-04-24 Fix compilation issues on VS2003 (Thanks Martin Spacek for
+ all the help) - MGD
+
2008-04-24 Fix sub/superscripts when the size of the font has been
changed - MGD
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-04-24 12:34:47 UTC (rev 5069)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-04-24 12:54:25 UTC (rev 5070)
@@ -270,8 +270,8 @@
double l, b, r, t;
if (py_convert_bbox(cliprect.ptr(), l, b, r, t)) {
- rasterizer->clip_box(int(round(l)) + 1, height - int(round(b)),
- int(round(r)), height - int(round(t)));
+ rasterizer->clip_box(int(mpl_round(l)) + 1, height - int(mpl_round(b)),
+ int(mpl_round(r)), height - int(mpl_round(t)));
}
_VERBOSE("RendererAgg::set_clipbox done");
@@ -807,7 +807,7 @@
if (gc.linewidth != 0.0) {
double linewidth = gc.linewidth;
if (!gc.isaa) {
- linewidth = (linewidth < 0.5) ? 0.5 : round(linewidth);
+ linewidth = (linewidth < 0.5) ? 0.5 : mpl_round(linewidth);
}
if (gc.dashes.size() == 0) {
stroke_t stroke(path);
@@ -1576,7 +1576,7 @@
int newwidth = 0;
int newheight = 0;
Py::String data;
- if (xmin < xmax and ymin < ymax) {
+ if (xmin < xmax && ymin < ymax) {
// Expand the bounds by 1 pixel on all sides
xmin = std::max(0, xmin - 1);
ymin = std::max(0, ymin - 1);
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2008-04-24 12:34:47 UTC (rev 5069)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-04-24 12:54:25 UTC (rev 5070)
@@ -6,12 +6,9 @@
#include "numpy/arrayobject.h"
#include "agg_path_storage.h"
#include "MPL_isnan.h"
+#include "mplutils.h"
#include <queue>
-static inline double my_round(double v) {
- return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
-}
-
class PathIterator
{
PyArrayObject* m_vertices;
@@ -161,8 +158,8 @@
cmd = m_source->vertex(x, y);
if (m_quantize && agg::is_vertex(cmd))
{
- *x = my_round(*x) + 0.5;
- *y = my_round(*y) + 0.5;
+ *x = mpl_round(*x) + 0.5;
+ *y = mpl_round(*y) + 0.5;
}
return cmd;
}
@@ -218,8 +215,8 @@
// Do any quantization if requested
if (m_quantize && agg::is_vertex(cmd))
{
- *x = my_round(*x) + 0.5;
- *y = my_round(*y) + 0.5;
+ *x = mpl_round(*x) + 0.5;
+ *y = mpl_round(*y) + 0.5;
}
//if we are starting a new path segment, move to the first point
Modified: trunk/matplotlib/src/mplutils.h
===================================================================
--- trunk/matplotlib/src/mplutils.h 2008-04-24 12:34:47 UTC (rev 5069)
+++ trunk/matplotlib/src/mplutils.h 2008-04-24 12:54:25 UTC (rev 5070)
@@ -1,4 +1,4 @@
-/* mplutils.h --
+/* mplutils.h --
*
* $Header$
* $Log$
@@ -26,6 +26,10 @@
#undef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+inline double mpl_round(double v) {
+ return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
+}
+
class Printf
{
private :
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-24 12:35:10
|
Revision: 5069
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5069&view=rev
Author: mdboom
Date: 2008-04-24 05:34:47 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Merged revisions 5061-5068 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
........
r5068 | mdboom | 2008-04-24 08:31:53 -0400 (Thu, 24 Apr 2008) | 2 lines
Fix sub/superscript placement when the size of font has been changed.
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/mathtext.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5060
+ /branches/v0_91_maint:1-5068
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-24 12:31:53 UTC (rev 5068)
+++ trunk/matplotlib/CHANGELOG 2008-04-24 12:34:47 UTC (rev 5069)
@@ -1,3 +1,6 @@
+2008-04-24 Fix sub/superscripts when the size of the font has been
+ changed - MGD
+
2008-04-22 Use "svg.embed_char_paths" consistently everywhere - MGD
2008-04-20 Add support to MaxNLocator for symmetric axis autoscaling. - EF
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-04-24 12:31:53 UTC (rev 5068)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-04-24 12:34:47 UTC (rev 5069)
@@ -651,7 +651,7 @@
# Some fonts don't store the xHeight, so we do a poor man's xHeight
metrics = self.get_metrics(font, 'it', 'x', fontsize, dpi)
return metrics.iceberg
- xHeight = pclt['xHeight'] / 64.0
+ xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0)
return xHeight
def get_underline_thickness(self, font, fontsize, dpi):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-24 12:31:58
|
Revision: 5068
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5068&view=rev
Author: mdboom
Date: 2008-04-24 05:31:53 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Fix sub/superscript placement when the size of font has been changed.
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/mathtext.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-04-24 12:20:23 UTC (rev 5067)
+++ branches/v0_91_maint/CHANGELOG 2008-04-24 12:31:53 UTC (rev 5068)
@@ -1,3 +1,6 @@
+2008-04-24 Fix sub/superscripts when the size of the font has been
+ changed - MGD
+
2008-04-22 Use "svg.embed_char_paths" consistently everywhere - MGD
2008-04-11 Fix global font rcParam setting after initialization
Modified: branches/v0_91_maint/lib/matplotlib/mathtext.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/mathtext.py 2008-04-24 12:20:23 UTC (rev 5067)
+++ branches/v0_91_maint/lib/matplotlib/mathtext.py 2008-04-24 12:31:53 UTC (rev 5068)
@@ -651,7 +651,7 @@
# Some fonts don't store the xHeight, so we do a poor man's xHeight
metrics = self.get_metrics(font, 'it', 'x', fontsize, dpi)
return metrics.iceberg
- xHeight = pclt['xHeight'] / 64.0
+ xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0)
return xHeight
def get_underline_thickness(self, font, fontsize, dpi):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-24 12:20:40
|
Revision: 5067
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5067&view=rev
Author: mdboom
Date: 2008-04-24 05:20:23 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Fix clipping bug in Wx backend.
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 2008-04-23 17:44:15 UTC (rev 5066)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-04-24 12:20:23 UTC (rev 5067)
@@ -283,13 +283,14 @@
if new_bounds is not None:
new_bounds = new_bounds.bounds
gfx_ctx = gc.gfx_ctx
- if gfx_ctx._lastcliprect != new_bounds:
+ if True or gfx_ctx._lastcliprect != new_bounds:
gfx_ctx._lastcliprect = new_bounds
if new_bounds is None:
gfx_ctx.ResetClip()
else:
- gfx_ctx.Clip(*new_bounds)
-
+ gfx_ctx.Clip(new_bounds[0], self.height - new_bounds[1] - new_bounds[3],
+ new_bounds[1], new_bounds[3])
+
#@staticmethod
def convert_path(gfx_ctx, tpath):
wxpath = gfx_ctx.CreatePath()
@@ -306,7 +307,7 @@
wxpath.CloseSubpath()
return wxpath
convert_path = staticmethod(convert_path)
-
+
def draw_path(self, gc, path, transform, rgbFace=None):
gc.select()
self.handle_clip_rectangle(gc)
@@ -331,7 +332,7 @@
gc.select()
self.handle_clip_rectangle(gc)
gfx_ctx = gc.gfx_ctx
-
+
font = self.get_wx_font(s, prop)
color = gc.get_wxcolour(gc.get_rgb())
gfx_ctx.SetFont(font, color)
@@ -347,7 +348,7 @@
xo = h * math.sin(rads)
yo = h * math.cos(rads)
gfx_ctx.DrawRotatedText(s, x - xo, y - yo, rads)
-
+
gc.unselect()
def new_gc(self):
@@ -423,7 +424,7 @@
wxGraphicsContext that draws to it. Creating a wxGraphicsContext
seems to be fairly heavy, so these objects are cached based on the
bitmap object that is passed in.
-
+
The base GraphicsContext stores colors as a RGB tuple on the unit
interval, eg, (0.5, 0.0, 1.0). wxPython uses an int interval, but
since wxPython colour management is rather simple, I have not chosen
@@ -442,7 +443,7 @@
'dashdot': wx.DOT_DASH,
'dotted': wx.DOT }
_cache = weakref.WeakKeyDictionary()
-
+
def __init__(self, bitmap, renderer):
GraphicsContextBase.__init__(self)
#assert self.Ok(), "wxMemoryDC not OK to use"
@@ -455,7 +456,7 @@
gfx_ctx = wx.GraphicsContext.Create(dc)
gfx_ctx._lastcliprect = None
self._cache[bitmap] = dc, gfx_ctx
-
+
self.bitmap = bitmap
self.dc = dc
self.gfx_ctx = gfx_ctx
@@ -463,7 +464,7 @@
gfx_ctx.SetPen(self._pen)
self._style = wx.SOLID
self.renderer = renderer
-
+
def select(self):
"""
Select the current bitmap into this wxDC instance
@@ -720,7 +721,7 @@
self.macros = {} # dict from wx id to seq of macros
self.Printer_Init()
-
+
def Destroy(self, *args, **kwargs):
wx.Panel.Destroy(self, *args, **kwargs)
@@ -877,7 +878,7 @@
def draw_idle(self, *args, **kwargs):
pass
-
+
def draw(self, repaint=True):
"""
Render the figure using RendererWx instance renderer, or using a
@@ -891,7 +892,7 @@
def flush_events(self):
wx.Yield()
-
+
def _get_imagesave_wildcards(self):
'return the wildcard string for the filesave dialog'
default_filetype = self.get_default_filetype()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-23 17:45:51
|
Revision: 5066
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5066&view=rev
Author: jdh2358
Date: 2008-04-23 10:44:15 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
added manuels scatter pie example
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/mlab.py
trunk/matplotlib/unit/mlab_unit.py
Added Paths:
-----------
trunk/matplotlib/examples/scatter_piecharts.py
Added: trunk/matplotlib/examples/scatter_piecharts.py
===================================================================
--- trunk/matplotlib/examples/scatter_piecharts.py (rev 0)
+++ trunk/matplotlib/examples/scatter_piecharts.py 2008-04-23 17:44:15 UTC (rev 5066)
@@ -0,0 +1,40 @@
+"""
+This example makes custom 'pie charts' as the markers for a scatter plotqu
+
+Thanks to Manuel Metz for the example
+"""
+import math
+import numpy as np
+import matplotlib.pyplot as plt
+
+# first define the ratios
+r1 = 0.2 # 20%
+r2 = r1 + 0.4 # 40%
+
+# define some sizes of the scatter marker
+sizes = [60,80,120]
+
+# calculate the points of the first pie marker
+#
+# these are just the origin (0,0) +
+# some points on a circle cos,sin
+x = [0] + np.cos(np.linspace(0, 2*math.pi*r1, 10)).tolist()
+y = [0] + np.sin(np.linspace(0, 2*math.pi*r1, 10)).tolist()
+xy1 = zip(x,y)
+
+# ...
+x = [0] + np.cos(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
+y = [0] + np.sin(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
+xy2 = zip(x,y)
+
+x = [0] + np.cos(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
+y = [0] + np.sin(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
+xy3 = zip(x,y)
+
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.scatter( np.arange(3), np.arange(3), marker=(xy1,0), s=sizes, facecolor='blue' )
+ax.scatter( np.arange(3), np.arange(3), marker=(xy2,0), s=sizes, facecolor='green' )
+ax.scatter( np.arange(3), np.arange(3), marker=(xy3,0), s=sizes, facecolor='red' )
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-23 16:54:21 UTC (rev 5065)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-23 17:44:15 UTC (rev 5066)
@@ -87,6 +87,7 @@
import numpy as npy
+
from matplotlib import nxutils
from matplotlib import cbook
@@ -2143,10 +2144,10 @@
def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
- converterd=None, names=None, missing=None):
+ converterd=None, names=None, missing='', missingd=None):
"""
Load data from comma/space/tab delimited file in fname into a
- numpy record array and return the record array.
+ numpy (m)record array and return the record array.
If names is None, a header row is required to automatically assign
the recarray names. The headers will be lower cased, spaces will
@@ -2172,13 +2173,24 @@
names, if not None, is a list of header names. In this case, no
header will be read from the file
+ missingd - is a dictionary mapping munged column names to field values
+ which signify that the field does not contain actual data and should
+ be masked, e.g. '0000-00-00' or 'unused'
+
+ missing - a string whose value signals a missing field regardless of
+ the column it appears in, e.g. 'unused'
+
if no rows are found, None is returned -- see examples/loadrec.py
"""
if converterd is None:
converterd = dict()
+ if missingd is None:
+ missingd = {}
+
import dateutil.parser
+ import datetime
parsedate = dateutil.parser.parse
@@ -2226,14 +2238,28 @@
process_skiprows(reader)
- dateparser = dateutil.parser.parse
+ def ismissing(name, val):
+ "Should the value val in column name be masked?"
- def myfloat(x):
- if x==missing:
- return npy.nan
+ if val == missing or val == missingd.get(name) or val == '':
+ return True
else:
- return float(x)
+ return False
+ def with_default_value(func, default):
+ def newfunc(name, val):
+ if ismissing(name, val):
+ return default
+ else:
+ return func(val)
+ return newfunc
+
+ dateparser = dateutil.parser.parse
+ mydateparser = with_default_value(dateparser, datetime.date(1,1,1))
+ myfloat = with_default_value(float, npy.nan)
+ myint = with_default_value(int, -1)
+ mystr = with_default_value(str, '')
+
def mydate(x):
# try and return a date object
d = dateparser(x)
@@ -2241,16 +2267,16 @@
if d.hour>0 or d.minute>0 or d.second>0:
raise ValueError('not a date')
return d.date()
+ mydate = with_default_value(mydate, datetime.date(1,1,1))
-
- def get_func(item, func):
+ def get_func(name, item, func):
# promote functions in this order
- funcmap = {int:myfloat, myfloat:mydate, mydate:dateparser, dateparser:str}
- try: func(item)
+ funcmap = {myint:myfloat, myfloat:mydate, mydate:mydateparser, mydateparser:mystr}
+ try: func(name, item)
except:
- if func==str:
+ if func==mystr:
raise ValueError('Could not find a working conversion function')
- else: return get_func(item, funcmap[func]) # recurse
+ else: return get_func(name, item, funcmap[func]) # recurse
else: return func
@@ -2266,7 +2292,7 @@
converters = None
for i, row in enumerate(reader):
if i==0:
- converters = [int]*len(row)
+ converters = [myint]*len(row)
if checkrows and i>checkrows:
break
#print i, len(names), len(row)
@@ -2276,10 +2302,10 @@
if func is None:
func = converterd.get(name)
if func is None:
- if not item.strip(): continue
+ #if not item.strip(): continue
func = converters[j]
if len(item.strip()):
- func = get_func(item, func)
+ func = get_func(name, item, func)
converters[j] = func
return converters
@@ -2307,7 +2333,7 @@
item = itemd.get(item, item)
cnt = seen.get(item, 0)
if cnt>0:
- names.append(item + '%d'%cnt)
+ names.append(item + '_%d'%cnt)
else:
names.append(item)
seen[item] = cnt+1
@@ -2327,15 +2353,24 @@
# iterate over the remaining rows and convert the data to date
# objects, ints, or floats as approriate
rows = []
+ rowmasks = []
for i, row in enumerate(reader):
if not len(row): continue
if row[0].startswith(comments): continue
- rows.append([func(val) for func, val in zip(converters, row)])
+ rows.append([func(name, val) for func, name, val in zip(converters, names, row)])
+ rowmasks.append([ismissing(name, val) for name, val in zip(names, row)])
fh.close()
if not len(rows):
return None
- r = npy.rec.fromrecords(rows, names=names)
+ if npy.any(rowmasks):
+ try: from numpy.ma import mrecords
+ except ImportError:
+ raise RuntimeError('numpy 1.05 or later is required for masked array support')
+ else:
+ r = mrecords.fromrecords(rows, names=names, mask=rowmasks)
+ else:
+ r = npy.rec.fromrecords(rows, names=names)
return r
@@ -2529,26 +2564,59 @@
-def rec2csv(r, fname, delimiter=',', formatd=None):
+def rec2csv(r, fname, delimiter=',', formatd=None, missing='',
+ missingd=None):
"""
- Save the data from numpy record array r into a comma/space/tab
+ Save the data from numpy (m)recarray r into a comma/space/tab
delimited file. The record array dtype names will be used for
column headers.
fname - can be a filename or a file handle. Support for gzipped
files is automatic, if the filename ends in .gz
+
+ See csv2rec and rec2csv for information about missing and
+ missingd, which can be used to fill in masked values into your CSV
+ file.
"""
+
+ if missingd is None:
+ missingd = dict()
+
+ def with_mask(func):
+ def newfunc(val, mask, mval):
+ if mask:
+ return mval
+ else:
+ return func(val)
+ return newfunc
+
formatd = get_formatd(r, formatd)
funcs = []
for i, name in enumerate(r.dtype.names):
- funcs.append(csvformat_factory(formatd[name]).tostr)
+ funcs.append(with_mask(csvformat_factory(formatd[name]).tostr))
fh, opened = cbook.to_filehandle(fname, 'w', return_opened=True)
writer = csv.writer(fh, delimiter=delimiter)
header = r.dtype.names
writer.writerow(header)
+
+ # Our list of specials for missing values
+ mvals = []
+ for name in header:
+ mvals.append(missingd.get(name, missing))
+
+ ismasked = False
+ if len(r):
+ row = r[0]
+ ismasked = hasattr(row, '_fieldmask')
+
for row in r:
- writer.writerow([func(val) for func, val in zip(funcs, row)])
+ if ismasked:
+ row, rowmask = row.item(), row._fieldmask.item()
+ else:
+ rowmask = [False] * len(row)
+ writer.writerow([func(val, mask, mval) for func, val, mask, mval
+ in zip(funcs, row, rowmask, mvals)])
if opened:
fh.close()
Modified: trunk/matplotlib/unit/mlab_unit.py
===================================================================
--- trunk/matplotlib/unit/mlab_unit.py 2008-04-23 16:54:21 UTC (rev 5065)
+++ trunk/matplotlib/unit/mlab_unit.py 2008-04-23 17:44:15 UTC (rev 5066)
@@ -55,5 +55,27 @@
print 'repr(dt.type)',repr(dt.type)
self.failUnless( numpy.all(ra[name] == ra2[name]) ) # should not fail with numpy 1.0.5
+ def test_csv2rec_masks(self):
+ # Make sure masked entries survive roundtrip
+
+ csv = """date,age,weight,name
+2007-01-01,12,32.2,"jdh1"
+0000-00-00,0,23,"jdh2"
+2007-01-03,,32.5,"jdh3"
+2007-01-04,12,NaN,"jdh4"
+2007-01-05,-1,NULL,"""
+ missingd = dict(date='0000-00-00', age='-1', weight='NULL')
+ fh = StringIO.StringIO(csv)
+ r1 = mlab.csv2rec(fh, missingd=missingd)
+ fh = StringIO.StringIO()
+ mlab.rec2csv(r1, fh, missingd=missingd)
+ fh.seek(0)
+ r2 = mlab.csv2rec(fh, missingd=missingd)
+
+ self.failUnless( numpy.all( r2['date'].mask == [0,1,0,0,0] ))
+ self.failUnless( numpy.all( r2['age'].mask == [0,0,1,0,1] ))
+ self.failUnless( numpy.all( r2['weight'].mask == [0,0,0,0,1] ))
+ self.failUnless( numpy.all( r2['name'].mask == [0,0,0,0,1] ))
+
if __name__=='__main__':
unittest.main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-23 16:54:23
|
Revision: 5065
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5065&view=rev
Author: efiring
Date: 2008-04-23 09:54:21 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
Allow for numpy 1.04, which does not have ma.masked_invalid
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/transforms.py
Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py 2008-04-23 12:37:58 UTC (rev 5064)
+++ trunk/matplotlib/lib/matplotlib/transforms.py 2008-04-23 16:54:21 UTC (rev 5065)
@@ -693,7 +693,10 @@
if len(xy) == 0:
return
- xym = ma.masked_invalid(xy)
+ try:
+ xym = ma.masked_invalid(xy) # maybe add copy=False
+ except AttributeError: # masked_invalid not exposed in npy 1.04
+ xym = ma.masked_where(~npy.isfinite(xy), xy)
if (xym.count(axis=1)!=2).all():
return
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-23 12:38:02
|
Revision: 5064
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5064&view=rev
Author: mdboom
Date: 2008-04-23 05:37:58 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
Use our own "round" function, since it doesn't appear to exist in VS2003
Modified Paths:
--------------
trunk/matplotlib/src/agg_py_path_iterator.h
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2008-04-23 07:21:03 UTC (rev 5063)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-04-23 12:37:58 UTC (rev 5064)
@@ -8,6 +8,10 @@
#include "MPL_isnan.h"
#include <queue>
+static inline double my_round(double v) {
+ return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
+}
+
class PathIterator
{
PyArrayObject* m_vertices;
@@ -157,8 +161,8 @@
cmd = m_source->vertex(x, y);
if (m_quantize && agg::is_vertex(cmd))
{
- *x = round(*x) + 0.5;
- *y = round(*y) + 0.5;
+ *x = my_round(*x) + 0.5;
+ *y = my_round(*y) + 0.5;
}
return cmd;
}
@@ -214,8 +218,8 @@
// Do any quantization if requested
if (m_quantize && agg::is_vertex(cmd))
{
- *x = round(*x) + 0.5;
- *y = round(*y) + 0.5;
+ *x = my_round(*x) + 0.5;
+ *y = my_round(*y) + 0.5;
}
//if we are starting a new path segment, move to the first point
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-23 07:21:22
|
Revision: 5063
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5063&view=rev
Author: efiring
Date: 2008-04-23 00:21:03 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
Update dataLim only if some valid data are available.
This change means that plot([nan]) will generate an
empty plot instead of raising an obscure exception.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/transforms.py
Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py 2008-04-22 18:55:36 UTC (rev 5062)
+++ trunk/matplotlib/lib/matplotlib/transforms.py 2008-04-23 07:21:03 UTC (rev 5063)
@@ -693,6 +693,9 @@
if len(xy) == 0:
return
+ xym = ma.masked_invalid(xy)
+ if (xym.count(axis=1)!=2).all():
+ return
points, minpos, changed = update_path_extents(
Path(xy), None, self._points, self._minpos, ignore)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-22 18:55:46
|
Revision: 5062
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5062&view=rev
Author: efiring
Date: 2008-04-22 11:55:36 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
Restore ability of backend_driver.py to drive cairo.svg, etc.
Modified Paths:
--------------
trunk/matplotlib/examples/backend_driver.py
Modified: trunk/matplotlib/examples/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/backend_driver.py 2008-04-22 15:09:24 UTC (rev 5061)
+++ trunk/matplotlib/examples/backend_driver.py 2008-04-22 18:55:36 UTC (rev 5062)
@@ -126,11 +126,6 @@
def drive(backend, python=['python'], switches = []):
exclude = failbackend.get(backend, [])
- # Strip off the format specifier, if any.
- if backend.startswith('cairo'):
- _backend = 'cairo'
- else:
- _backend = backend
# Clear the destination directory for the examples
path = backend
@@ -163,7 +158,7 @@
tmpfile.writelines((
'from __future__ import division\n',
'import matplotlib\n',
- 'matplotlib.use("%s")\n' % _backend,
+ 'matplotlib.use("%s")\n' % backend,
'from pylab import savefig\n',
))
for line in file(fname):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|