Skip to content

Commit ad74c3f

Browse files
committed
Lots of minor bug fixes.
svn path=/branches/transforms/; revision=4053
1 parent a1e0f3d commit ad74c3f

File tree

12 files changed

+304
-102
lines changed

12 files changed

+304
-102
lines changed

PASSED_DEMOS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,5 @@ wxcursor_demo.py O
208208
xcorr_demo.py O
209209
zoom_window.py O
210210
zorder_demo.py O
211+
212+
MGDTODO: units directory

lib/matplotlib/artist.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re, warnings
33
from cbook import iterable, flatten
44
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
5+
from path import Path
56

67
## Note, matplotlib artists use the doc strings for set and get
78
# methods to enable the introspection methods of setp and getp. Every
@@ -285,25 +286,48 @@ def set_clip_box(self, clipbox):
285286

286287
def set_clip_path(self, path, transform=None):
287288
"""
288-
Set the artist's clip path
289+
Set the artist's clip path, which may be:
289290
290-
ACCEPTS: a Path instance and a Transform instance, or a Patch instance
291+
a) a Patch (or subclass) instance
292+
293+
b) a Path instance, in which cas aoptional transform may
294+
be provided, which will be applied to the path before using it
295+
for clipping.
296+
297+
c) None, to remove the clipping path
298+
299+
For efficiency, if the path happens to be an axis-aligned
300+
rectangle, this method will set the clipping box to the
301+
corresponding rectangle and set the clipping path to None.
302+
303+
ACCEPTS: a Path instance and a Transform instance, a Patch
304+
instance, or None
291305
"""
292306
from patches import Patch, Rectangle
307+
308+
success = False
293309
if transform is None:
294310
if isinstance(path, Rectangle):
295311
self.clipbox = TransformedBbox(Bbox.unit(), path.get_transform())
312+
success = True
296313
elif isinstance(path, Patch):
297314
self._clippath = TransformedPath(
298315
path.get_path(),
299316
path.get_transform())
300-
elif path is None:
301-
self._clippath = None
302-
else:
303-
raise TypeError("Invalid arguments to set_clip_path")
304-
else:
317+
success = True
318+
319+
if path is None:
320+
self._clippath = None
321+
success = True
322+
elif isinstance(path, Path):
305323
self._clippath = TransformedPath(path, transform)
306-
self._clipon = self.clipbox is not None or path is not None
324+
success = True
325+
326+
if not success:
327+
print type(path), type(transform)
328+
raise TypeError("Invalid arguments to set_clip_path")
329+
330+
self._clipon = self.clipbox is not None or self._clippath is not None
307331
self.pchanged()
308332

309333
def get_alpha(self):
@@ -334,6 +358,10 @@ def get_clip_path(self):
334358
return self._clippath
335359

336360
def get_transformed_clip_path_and_affine(self):
361+
'''
362+
Return the clip path with the non-affine part of its transformation applied,
363+
and the remaining affine part of its transformation.
364+
'''
337365
if self._clippath is not None:
338366
return self._clippath.get_transformed_path_and_affine()
339367
return None, None

0 commit comments

Comments
 (0)