[matplotlib-devel] Scatter plot legend

2008-03-14 Thread Paul Novak
A few weeks ago there was a discussion about putting scatter symbols in 
the legend (see 
http://www.nabble.com/Show-shapes-on-scatterplot-legend--to15744380.html).

I would like to implement scatter symbols in the legend, but I am having 
some problems doing so. In the function _get_handles in legend.py, the 
symbol can be placed in the legend by doing something like:

for path in handle._paths:
 xy = path.vertices
p = Polygon(xy)

The problem is that the polygon that gets drawn is the wrong size and 
aspect ratio. It would seem that this would call for some sort of 
scaling or transform to make the symbol the proper size, but I need some 
assistance or a pointer to documentation on how to do this.

Thanks,

Paul Novak

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Scatter plot legend

2008-05-09 Thread Paul Novak
Hello,

I'm still interested in having a polygon symbol in the legend for a 
scatter plot. I've made some changes to the suggestion of Manuel Metz to 
make the legend symbol look better (the code-fragment from legend.py is 
below). But when resizing the window, the symbol gets stretched and 
placed in a bad location; it appears that the symbol is stretched and 
scaled in the same manner as the legend box as a whole, while I think it 
would look better if the symbol maintained the same size and aspect 
ratio, but merely moved to the appropriate location within the resized 
legend.

I would like to add this functionality, but I need some help to 
understand the required transformations or scaling to make it look good. 
Perhaps someone with a better understanding could provide some help?

Thanks,
Paul Novak



 elif isinstance(handle, RegularPolyCollection):
 if self.numpoints == 1:
 xdata = np.array([left])

 for path in handle.get_paths():
 xy = path.vertices

 p = Polygon(xy)

 x = min(xdata)
 y = y-0.5*HEIGHT
# 0.35 * HEIGHT makes the legend symbol an appropriate size.
# patch_aspect scales the legend symbol to the appropriate aspect ratio.
 patch_aspect = (max(xy[:,0]) - min(xy[:,0])) / 
(max(xy[:,1]) - min(xy[:,1]))
 bbox = Bbox.from_bounds(x, y, 0.35 * HEIGHT, 0.35 * 
HEIGHT * patch_aspect)
 p.set_facecolor(handle._facecolors[0])
 if handle._edgecolors != 'None':
 p.set_edgecolor(handle._edgecolors[0])
 self._set_artist_props(p)
# HERE IS THE ADDITIONAL TRANSFORM FOR THE POLY
 p.set_transform( BboxTransformTo(bbox) + 
p.get_transform() )

 p.set_clip_box(None)
 p.set_clip_path(None)
 ret.append(p)



-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel