Skip to content

Commit ce9bade

Browse files
committed
Merged revisions 4773-4785 via svnmerge from
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4783 | mdboom | 2007-12-21 10:08:38 -0500 (Fri, 21 Dec 2007) | 2 lines Add size-dependent highly-accurate arc drawing. ........ r4785 | jdh2358 | 2007-12-21 11:22:42 -0500 (Fri, 21 Dec 2007) | 2 lines added unit support to arc ........ svn path=/branches/transforms/; revision=4787
1 parent cdf658d commit ce9bade

File tree

8 files changed

+189
-106
lines changed

8 files changed

+189
-106
lines changed

API_CHANGES

+3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ TRANSFORMS REFACTORING
169169

170170
END OF TRANSFORMS REFACTORING
171171

172+
For csv2rec, checkrows=0 is the new default indicating all rows
173+
will be checked for type inference
174+
172175
A warning is issued when an image is drawn on log-scaled
173176
axes, since it will not log-scale the image data.
174177

CODING_GUIDE

+14-23
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk matplotli
1212
# checking out the main src
1313
svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib --username=youruser --password=yourpass
1414

15+
# branch checkouts, eg the transforms branch
16+
svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/transforms transbranch
17+
1518
== Committing changes ==
1619

1720
When committing changes to matplotlib, there are a few things to bear
@@ -27,12 +30,6 @@ in mind.
2730
support 2.3, so avoid 2.4 only features like decorators until we
2831
remove 2.3 support
2932

30-
* Are your changes Numeric, numarray and numpy compatible? Try
31-
running simple_plot.py or image_demo.py with --Numeric, --numarray
32-
and --numpy (Note, someone should add examples to
33-
backend_driver.py which explicitly require numpy, numarray and
34-
Numeric so we can automatically catch these)
35-
3633
* Can you pass examples/backend_driver.py? This is our poor man's
3734
unit test.
3835

@@ -49,9 +46,8 @@ in mind.
4946
For numpy, use:
5047

5148
import numpy as npy
52-
...
5349
a = npy.array([1,2,3])
54-
...
50+
5551

5652
For masked arrays, use:
5753
import matplotlib.numerix.npyma as ma
@@ -64,15 +60,19 @@ For masked arrays, use:
6460
For matplotlib main module, use:
6561

6662
import matplotlib as mpl
67-
...
6863
mpl.rcParams['xtick.major.pad'] = 6
6964

70-
For matplotlib modules, use:
65+
For matplotlib modules (or any other modules), use:
66+
67+
import matplotlib.cbook as cbook
68+
69+
if cbook.iterable(z):
70+
pass
7171

72-
import matplotlib.cbook as cbook as mpl_cbook
73-
...
74-
if mpl_cbook.iterable(z):
75-
...
72+
We prefer this over the equivalent 'from matplotlib import cbook'
73+
because the latter is ambiguous whether cbook is a module or a
74+
function to the new developer. The former makes it explcit that
75+
you are importing a module or package.
7676

7777
== Naming, spacing, and formatting conventions ==
7878

@@ -114,15 +114,6 @@ noise in svn diffs. If you are an emacs user, the following in your
114114
python, C and C++
115115

116116

117-
When importing modules from the matplotlib namespace
118-
119-
import matplotlib.cbook as cbook # DO
120-
from matplotlib import cbook #DONT
121-
122-
because the latter is ambiguous whether cbook is a module or a
123-
function to the new developer. The former makes it explcit that you
124-
are importing a module or package.
125-
126117
; and similarly for c++-mode-hook and c-mode-hook
127118
(add-hook 'python-mode-hook
128119
(lambda ()

examples/units/ellipse_with_units.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Compare the ellipse generated with arcs versus a polygonal approximation
2+
Compare the ellipse generated with arcs versus a polygonal approximation
33
"""
44
from basic_units import cm
55
import numpy as npy
@@ -46,4 +46,24 @@
4646
#fig.savefig('ellipse_compare.png')
4747
fig.savefig('ellipse_compare')
4848

49+
fig = figure()
50+
ax = fig.add_subplot(211, aspect='auto')
51+
ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, zorder=1)
52+
53+
e1 = patches.Arc((xcenter, ycenter), width, height,
54+
angle=angle, linewidth=2, fill=False, zorder=2)
55+
56+
ax.add_patch(e1)
57+
58+
ax = fig.add_subplot(212, aspect='equal')
59+
ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
60+
e2 = patches.Arc((xcenter, ycenter), width, height,
61+
angle=angle, linewidth=2, fill=False, zorder=2)
62+
63+
64+
ax.add_patch(e2)
65+
66+
#fig.savefig('arc_compare.png')
67+
fig.savefig('arc_compare')
68+
4969
show()

lib/matplotlib/axes.py

+4
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ def makeline(x, y):
321321
ret.append(seg)
322322

323323
def makefill(x, y):
324+
x = self.axes.convert_xunits(x)
325+
y = self.axes.convert_yunits(y)
324326
facecolor = self._get_next_cycle_color()
325327
seg = mpatches.Polygon(zip(x, y),
326328
facecolor = facecolor,
@@ -363,6 +365,8 @@ def makeline(x, y):
363365

364366
def makefill(x, y):
365367
facecolor = color
368+
x = self.axes.convert_xunits(x)
369+
y = self.axes.convert_yunits(y)
366370
seg = mpatches.Polygon(zip(x, y),
367371
facecolor = facecolor,
368372
fill=True,

lib/matplotlib/legend.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(self, parent, handles, labels,
140140
self._offsetTransform = Affine2D()
141141
self._parentTransform = BboxTransformTo(parent.bbox)
142142
Artist.set_transform(self, self._offsetTransform + self._parentTransform)
143-
143+
144144
if loc is None:
145145
loc = rcParams["legend.loc"]
146146
if not self.isaxes and loc in [0,'best']:
@@ -226,7 +226,7 @@ def _get_handle_text_bbox(self, renderer):
226226
bboxesAll = bboxesText
227227
bboxesAll.extend(bboxesHandles)
228228
bbox = Bbox.union(bboxesAll)
229-
229+
230230
self.save = bbox
231231

232232
ibox = bbox.inverse_transformed(self.get_transform())
@@ -328,7 +328,7 @@ def _auto_legend_data(self):
328328

329329
if isinstance(handle, Rectangle):
330330
transform = handle.get_data_transform() + inverse_transform
331-
bboxes.append(handle._bbox.transformed(transform))
331+
bboxes.append(handle.get_bbox().transformed(transform))
332332
else:
333333
transform = handle.get_transform() + inverse_transform
334334
bboxes.append(handle.get_path().get_extents(transform))
@@ -499,7 +499,7 @@ def get_tbounds(text): #get text bounds in axes coords
499499
bbox = bbox.expanded(1 + self.pad, 1 + self.pad)
500500
l, b, w, h = bbox.bounds
501501
self.legendPatch.set_bounds(l, b, w, h)
502-
502+
503503
ox, oy = 0, 0 # center
504504

505505
if iterable(self._loc) and len(self._loc)==2:

lib/matplotlib/mlab.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,7 @@ def key_desc(name):
20452045
return newrec.view(npy.recarray)
20462046

20472047

2048-
def csv2rec(fname, comments='#', skiprows=0, checkrows=5, delimiter=',',
2048+
def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
20492049
converterd=None, names=None, missing=None):
20502050
"""
20512051
Load data from comma/space/tab delimited file in fname into a
@@ -2075,7 +2075,7 @@ def csv2rec(fname, comments='#', skiprows=0, checkrows=5, delimiter=',',
20752075
names, if not None, is a list of header names. In this case, no
20762076
header will be read from the file
20772077
2078-
if no rows are found, None is returned See examples/loadrec.py
2078+
if no rows are found, None is returned -- see examples/loadrec.py
20792079
"""
20802080

20812081
if converterd is None:

0 commit comments

Comments
 (0)