8000 Merged revisions 3836-3846 via svnmerge from · matplotlib/matplotlib@abd4723 · GitHub
[go: up one dir, main page]

Skip to content

Commit abd4723

Browse files
committed
Merged revisions 3836-3846 via svnmerge from
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r3844 | jdh2358 | 2007-09-12 16:37:41 -0400 (Wed, 12 Sep 2007) | 1 line fixed a bar units bug ........ r3845 | jouni | 2007-09-13 02:29:14 -0400 (Thu, 13 Sep 2007) | 3 lines More work on dviread and usetex in pdf. It is more usable now, so I am renaming the method from _draw_tex to draw_tex. ........ svn path=/branches/transforms/; revision=3847
2 parents 0732364 + 0e5344a commit abd4723

File tree

10 files changed

+170
-71
lines changed

10 files changed

+170
-71
lines changed

API_CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Made skiprows=1 the default on csv2rec
2+
13
The gd and paint backends have been deleted.
24

35
The errorbar method and function now accept additional kwargs

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2007-09-13 The usetex support in the pdf backend is more usable now,
2+
so I am enabling it. - JKS
3+
4+
2007-09-12 Fixed a Axes.bar unit bug - JDH
5+
6+
2007-09-10 Made skiprows=1 the default on csv2rec - JDH
7+
18
2007-09-09 Split out the plotting part of pylab and put it in
29
pyplot.py; removed numerix from the remaining pylab.py,
310
which imports everything from pyplot.py. The intention

examples/units/bar_demo2.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
plot using a variety of cm vs inches conversions. The example shows
3+
how default unit instrospection works (ax1), how various keywords can
4+
be used to set the x and y units to override the defaults (ax2, ax3,
5+
ax4) and how one can set the xlimits using scalars (ax3, current units
6+
assumed) or units (conversions applied to get the numbers to current
7+
units)
8+
9+
"""
10+
from basic_units import cm, inch
11+
from pylab import figure, show, nx
12+
13+
cms = cm *nx.arange(0, 10, 2)
14+
bottom=0*cm
15+
width=0.8*cm
16+
17+
fig = figure()
18+
19+
ax1 = fig.add_subplot(2,2,1)
20+
ax1.bar(cms, cms, bottom=bottom)
21+
22+
ax2 = fig.add_subplot(2,2,2)
23+
ax2.bar(cms, cms, bottom=bottom, width=width, xunits=cm, yunits=inch)
24+
25+
ax3 = fig.add_subplot(2,2,3)
26+
ax3.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=cm)
27+
ax3.set_xlim(3, 6) # scalars are interpreted in current units
28+
29+
ax4 = fig.add_subplot(2,2,4)
30+
ax4.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=inch)
31+
#fig.savefig('simple_conversion_plot.png')
32+
ax4.set_xlim(3*cm, 6*cm) # cm are converted to inches
33+
34+
show()

lib/matplotlib/artist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self):
5151
self._remove_method = None
5252

5353
def remove(self):
54-
'''
54+
"""
5555
Remove the artist from the figure if possible. The effect will not
5656
be visible until the figure is redrawn, e.g., with ax.draw_idle().
5757
Call ax.relim() to update the axes limits if desired.
@@ -60,7 +60,7 @@ def remove(self):
6060
was added to axes with autolim=True.
6161
6262
Note: there is no support for removing the artist's legend entry.
63-
'''
63+
"""
6464

6565
# There is no method to set the callback. Instead the parent should set
6666
# the _remove_method attribute directly. This would be a protected

lib/matplotlib/axes.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,23 +1193,27 @@ def _get_verts_in_data_coords(self, trans, xys):
11931193
def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
11941194
'look for unit kwargs and update the axis instances as necessary'
11951195

1196-
if self.xaxis is None or self.xaxis is None: return
1197-
1196+
if self.xaxis is None or self.yaxis is None: return
11981197

1198+
#print 'processing', self.get_geometry()
11991199
if xdata is not None:
12001200
self.xaxis.update_units(xdata)
1201+
#print '\tset from xdata', self.xaxis.units
12011202

12021203
if ydata is not None:
12031204
self.yaxis.update_units(ydata)
1205+
#print '\tset from ydata', self.yaxis.units
12041206

12051207
# process kwargs 2nd since these will override default units
12061208
if kwargs is not None:
12071209
xunits = kwargs.pop( 'xunits', self.xaxis.units)
12081210
if xunits!=self.xaxis.units:
1211+
#print '\tkw setting xunits', xunits
12091212
self.xaxis.set_units(xunits)
12101213

12111214
yunits = kwargs.pop('yunits', self.yaxis.units)
12121215
if yunits!=self.yaxis.units:
1216+
#print '\tkw setting yunits', yunits
12131217
self.yaxis.set_units(yunits)
12141218

12151219
def in_axes(self, xwin, ywin):
@@ -3122,10 +3126,12 @@ def make_iterable(x):
31223126
else:
31233127
raise ValueError, 'invalid orientation: %s' % orientation
31243128

3125-
left = npy.asarray(left)
3126-
height = npy.asarray(height)
3127-
width = npy.asarray(width)
3128-
bottom = npy.asarray(bottom)
3129+
3130+
# do not convert to array here as unit info is lost
3131+
#left = npy.asarray(left)
3132+
#height = npy.asarray(height)
3133+
#width = npy.asarray(width)
3134+
#bottom = npy.asarray(bottom)
31293135

31303136
if len(linewidth) == 1: linewidth = linewidth * nbars
31313137

@@ -3169,14 +3175,14 @@ def make_iterable(x):
31693175
# lets do some conversions now
31703176
if self.xaxis is not None:
31713177
xconv = self.xaxis.converter
3172-
if ( xconv ):
3178+
if xconv is not None:
31733179
units = self.xaxis.get_units()
31743180
left = xconv.convert( left, units )
31753181
width = xconv.convert( width, units )
31763182

31773183
if self.yaxis is not None:
31783184
yconv = self.yaxis.converter
3179-
if ( yconv ):
3185+
if yconv is not None :
31803186
units = self.yaxis.get_units()
31813187
bottom = yconv.convert( bottom, units )
31823188
height = yconv.convert( height, units )
@@ -3216,12 +3222,14 @@ def make_iterable(x):
32163222

32173223
if xerr is not None or yerr is not None:
32183224
if orientation == 'vertical':
3219-
x = left + 0.5*width
3220-
y = bottom + height
3225+
# using list comps rather than arrays to preserve unit info
3226+
x = [l+0.5*w for l, w in zip(left, width)]
3227+
y = [b+h for b,h in zip(bottom, height)]
32213228

32223229
elif orientation == 'horizontal':
3223-
x = left + width
3224-
y = bottom + 0.5*height
3230+
# using list comps rather than arrays to preserve unit info
3231+
x = [l+w for l,w in zip(left, width)]
3232+
y = [b+0.5*h for b,h in zip(bottom, height)]
32253233

32263234
self.errorbar(
32273235
x, y,

lib/matplotlib/axis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ def convert_units(self, x):
821821
return x
822822

823823
ret = self.converter.convert(x, self.units)
824-
#print 'convert_units converting: units=%s, converter=%s, in=%s, out=%s'%(self.units, self.converter, x, ret)
824+
#print 'convert_units converting: axis=%s, units=%s, converter=%s, in=%s, out=%s'%(self, self.units, self.converter, x, ret)
825825
return ret
826826

827827
def set_units(self, u):

lib/matplotlib/backends/backend_pdf.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def embedType1(self, filename, fontinfo):
527527
widths.append(afmdata.get_width_from_char_name(ch))
528528
except KeyError:
529529
matplotlib.verbose.report(
530-
'No width for %s in %s' % (ch, fullname), 'debug')
530+
'No width for %s in %s' % (ch, fullname), 'debug-annoying')
531531
widths.append(0)
532532

533533
differencesArray = [ Name(ch) for ch in enc ]
@@ -561,7 +561,7 @@ def embedType1(self, filename, fontinfo):
561561
except KeyError:
562562
matplotlib.verbose.report(
563563
'No name for glyph %d in %s' % (ch, fullname),
564-
'debug')
564+
'debug-annoying')
565565
need_idx = True
566566

567567

@@ -1449,9 +1449,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
14491449
# Pop off the global transformation
14501450
self.file.output(Op.grestore)
14511451

1452-
def _draw_tex(self, gc, x, y, s, prop, angle):
1453-
# Rename to draw_tex to enable
1454-
1452+
def draw_tex(self, gc, x, y, s, prop, angle):
14551453
texmanager = self.get_texmanager()
14561454
fontsize = prop.get_size_in_points()
14571455
dvifile = texmanager.make_dvi(s, fontsize)
@@ -1494,7 +1492,7 @@ def mytrans(x1, y1, x=x, y=y, a=angle / 180.0 * pi):
14941492
elt[3][-1] += next[3][0]
14951493
elt[4] += next[4]-next[1]
14961494
else:
1497-
elt[3] += [offset, next[3][0]]
1495+
elt[3] += [offset*1000.0/dvifont.size, next[3][0]]
14981496
elt[4] = next[4]
14991497
del seq[i+1]
15001498
continue

0 commit comments

Comments
 (0)
0