Skip to content

Commit 2247c2d

Browse files
committed
added scatter legends from john gill
svn path=/trunk/matplotlib/; revision=1850
1 parent 85b56d3 commit 2247c2d

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
New entries should be added at the top
22

3+
2005-10-26 Added support for scatter legends - thanks John Gill
4+
5+
2005-10-20 Fixed image clipping bug that made some tex labels
6+
disappear. Closes bug - JDH
7+
38
2005-10-14 Removed aqrt from dvipng 1.6 alpha channel mask. Where did
49
that come from?
510

TODO

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,4 +728,9 @@ ZeroDivisionError: SeparableTransformation::eval_scalars yin interval is zero; c
728728

729729
-- restore robert leftwich's tutorial link to FAQ
730730

731-
-- JPL and NIST screenshots...
731+
-- JPL and NIST screenshots...
732+
733+
-- John Gill's patch!
734+
735+
-- Fix latex texmanager caching bug that is preventing the cache from
736+
recognizing a font change

lib/matplotlib/font_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ def createFontDict(fontfiles, fontext='ttf'):
452452
except RuntimeError:
453453
warnings.warn("Could not open font file %s"%fpath)
454454
continue
455+
except UnicodeError:
456+
warnings.warn("Cannot handle unicode filenames %s"%fpath)
457+
continue
455458
try: prop = ttfFontProperty(font)
456459
except: continue
457460

lib/matplotlib/legend.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from font_manager import FontProperties
3232
from lines import Line2D
3333
from mlab import linspace, segments_intersect
34-
from patches import Patch, Rectangle, Shadow, bbox_artist, draw_bbox
35-
from collections import LineCollection
34+
from patches import Patch, Rectangle, RegularPolygon, Shadow, bbox_artist, draw_bbox
35+
from collections import LineCollection, RegularPolyCollection, PatchCollection
3636
from text import Text
3737
from transforms import Bbox, Point, Value, get_bbox_transform, bbox_all,\
3838
unit_bbox, inverse_transform_bbox, lbwh_to_bbox
@@ -282,6 +282,18 @@ def _get_handles(self, handles, texts):
282282
legline.set_dashes(dashes)
283283
ret.append(legline)
284284

285+
elif isinstance(handle, RegularPolyCollection):
286+
287+
p = Rectangle(xy=(min(self._xdata), y-3/4*HEIGHT),
288+
width = self.handlelen, height=HEIGHT/2,
289+
)
290+
p.set_facecolor(handle._facecolors[0])
291+
if handle._edgecolors != 'None':
292+
p.set_edgecolor(handle._edgecolors[0])
293+
self._set_artist_props(p)
294+
p.set_clip_box(None)
295+
ret.append(p)
296+
285297
else:
286298
ret.append(None)
287299

@@ -307,6 +319,7 @@ def get_handles(ax):
307319
handles = ax.lines
308320
handles.extend(ax.patches)
309321
handles.extend([c for c in ax.collections if isinstance(c, LineCollection)])
322+
310323
return handles
311324

312325
ax = self.parent
@@ -411,6 +424,8 @@ def _offset(self, ox, oy):
411424
elif isinstance(h, Rectangle):
412425
h.xy[0] = h.xy[0] + ox
413426
h.xy[1] = h.xy[1] + oy
427+
elif isinstance(h, RegularPolygon):
428+
h.verts = [(x + ox, y + oy) for x, y in h.verts]
414429

415430
x, y = self.legendPatch.get_x(), self.legendPatch.get_y()
416431
self.legendPatch.set_x(x+ox)

0 commit comments

Comments
 (0)