Skip to content

Commit

Permalink
Merged revisions 4773-4785 via svnmerge from
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdboom committed Dec 21, 2007
1 parent cdf658d commit ce9bade
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 106 deletions.
3 changes: 3 additions & 0 deletions API_CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ TRANSFORMS REFACTORING

END OF TRANSFORMS REFACTORING

For csv2rec, checkrows=0 is the new default indicating all rows
will be checked for type inference

A warning is issued when an image is drawn on log-scaled
axes, since it will not log-scale the image data.

Expand Down
37 changes: 14 additions & 23 deletions CODING_GUIDE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk matplotli
# checking out the main src
svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib --username=youruser --password=yourpass

# branch checkouts, eg the transforms branch
svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/transforms transbranch

== Committing changes ==

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

* Are your changes Numeric, numarray and numpy compatible? Try
running simple_plot.py or image_demo.py with --Numeric, --numarray
and --numpy (Note, someone should add examples to
backend_driver.py which explicitly require numpy, numarray and
Numeric so we can automatically catch these)

* Can you pass examples/backend_driver.py? This is our poor man's
unit test.

Expand All @@ -49,9 +46,8 @@ in mind.
For numpy, use:

import numpy as npy
...
a = npy.array([1,2,3])
...


For masked arrays, use:
import matplotlib.numerix.npyma as ma
Expand All @@ -64,15 +60,19 @@ For masked arrays, use:
For matplotlib main module, use:

import matplotlib as mpl
...
mpl.rcParams['xtick.major.pad'] = 6

For matplotlib modules, use:
For matplotlib modules (or any other modules), use:

import matplotlib.cbook as cbook

if cbook.iterable(z):
pass

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

== Naming, spacing, and formatting conventions ==

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


When importing modules from the matplotlib namespace

import matplotlib.cbook as cbook # DO
from matplotlib import cbook #DONT

because the latter is ambiguous whether cbook is a module or a
function to the new developer. The former makes it explcit that you
are importing a module or package.

; and similarly for c++-mode-hook and c-mode-hook
(add-hook 'python-mode-hook
(lambda ()
Expand Down
22 changes: 21 additions & 1 deletion examples/units/ellipse_with_units.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Compare the ellipse generated with arcs versus a polygonal approximation
Compare the ellipse generated with arcs versus a polygonal approximation
"""
from basic_units import cm
import numpy as npy
Expand Down Expand Up @@ -46,4 +46,24 @@
#fig.savefig('ellipse_compare.png')
fig.savefig('ellipse_compare')

fig = figure()
ax = fig.add_subplot(211, aspect='auto')
ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, zorder=1)

e1 = patches.Arc((xcenter, ycenter), width, height,
angle=angle, linewidth=2, fill=False, zorder=2)

ax.add_patch(e1)

ax = fig.add_subplot(212, aspect='equal')
ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
e2 = patches.Arc((xcenter, ycenter), width, height,
angle=angle, linewidth=2, fill=False, zorder=2)


ax.add_patch(e2)

#fig.savefig('arc_compare.png')
fig.savefig('arc_compare')

show()
4 changes: 4 additions & 0 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ def makeline(x, y):
ret.append(seg)

def makefill(x, y):
x = self.axes.convert_xunits(x)
y = self.axes.convert_yunits(y)
facecolor = self._get_next_cycle_color()
seg = mpatches.Polygon(zip(x, y),
facecolor = facecolor,
Expand Down Expand Up @@ -363,6 +365,8 @@ def makeline(x, y):

def makefill(x, y):
facecolor = color
x = self.axes.convert_xunits(x)
y = self.axes.convert_yunits(y)
seg = mpatches.Polygon(zip(x, y),
facecolor = facecolor,
fill=True,
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self, parent, handles, labels,
self._offsetTransform = Affine2D()
self._parentTransform = BboxTransformTo(parent.bbox)
Artist.set_transform(self, self._offsetTransform + self._parentTransform)

if loc is None:
loc = rcParams["legend.loc"]
if not self.isaxes and loc in [0,'best']:
Expand Down Expand Up @@ -226,7 +226,7 @@ def _get_handle_text_bbox(self, renderer):
bboxesAll = bboxesText
bboxesAll.extend(bboxesHandles)
bbox = Bbox.union(bboxesAll)

self.save = bbox

ibox = bbox.inverse_transformed(self.get_transform())
Expand Down Expand Up @@ -328,7 +328,7 @@ def _auto_legend_data(self):

if isinstance(handle, Rectangle):
transform = handle.get_data_transform() + inverse_transform
bboxes.append(handle._bbox.transformed(transform))
bboxes.append(handle.get_bbox().transformed(transform))
else:
transform = handle.get_transform() + inverse_transform
bboxes.append(handle.get_path().get_extents(transform))
Expand Down Expand Up @@ -499,7 +499,7 @@ def get_tbounds(text): #get text bounds in axes coords
bbox = bbox.expanded(1 + self.pad, 1 + self.pad)
l, b, w, h = bbox.bounds
self.legendPatch.set_bounds(l, b, w, h)

ox, oy = 0, 0 # center

if iterable(self._loc) and len(self._loc)==2:
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ def key_desc(name):
return newrec.view(npy.recarray)


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

if converterd is None:
Expand Down
Loading

0 comments on commit ce9bade

Please sign in to comment.