hmm
-------- Original Message --------
Jae-Joon Lee wrote:
>> - the parameter numpoints should be used (it's ignored right now)
>>
>
> Thanks Manuel. I guess we can simply reuse xdata_marker for this purpose.
>
>
>> - Some private variables are accessed and a new RegularPolycollection is
>> created (does this work eg. with a StarPolygonCollection? I haven't
>> checked, but I don't think so !). Instead of creating a new
>> RegularPolyCollection it might be more useful to make a copy of the
>> existing object... I was thinking about a update_from() method for the
>> Collection class(es) similar to update_from() for lines.
>>
>
> By changing "RegularPolyCoolection" to "type(handles)", it works for
> StarPolygonCollection.
>
> In Erik's current implementation, the markers in the legend have
> varying colors, sizes, and y offsets.
> The color variation seems fine. But do we need to vary the sizes and
> y-offsets? My inclination is to use a fixed size (median?) and a fixed
> y offset. How does Erik and others think?
>
> Regards,
>
> -JJ
Attached is my current version of the patch. I've moved all of the
properties-copying stuff to collections, which makes the changes
legend.py more clearer (but I'm not fully happy with the patch and
haven't commit anything yet)
mm
--
---------------------------------------
Manuel Metz ............ [EMAIL PROTECTED]
Argelander Institut fuer Astronomie
Auf dem Huegel 71 (room 3.06)
D - 53121 Bonn
E-Mail: [EMAIL PROTECTED]
Web: www.astro.uni-bonn.de/~mmetz
Phone: (+49) 228 / 73-3660
Fax: (+49) 228 / 73-3672
---------------------------------------
Index: legend.py
===================================================================
--- legend.py (revision 6211)
+++ legend.py (working copy)
@@ -306,15 +306,14 @@
ret.append(legline)
elif isinstance(handle, RegularPolyCollection):
- if self.numpoints == 1:
- xdata = np.array([left])
- p = Rectangle(xy=(min(xdata), y-3/4*HEIGHT),
- width = self.handlelen, height=HEIGHT/2,
- )
- p.set_facecolor(handle._facecolors[0])
- if handle._edgecolors != 'none' and len(handle._edgecolors):
- p.set_edgecolor(handle._edgecolors[0])
- self._set_artist_props(p)
+ ydata = (y-HEIGHT/2)*np.ones(xdata.shape, float)
+
+ p = RegularPolyCollection(handle.get_numsides(),
+ offsets=zip(xdata,ydata),
+ transOffset=self.get_transform())
+
+ p.update_from(handle)
+ p.set_figure(self.figure)
p.set_clip_box(None)
p.set_clip_path(None)
ret.append(p)
Index: collections.py
===================================================================
--- collections.py (revision 6211)
+++ collections.py (working copy)
@@ -148,6 +148,12 @@
result = result.inverse_transformed(transData)
return result
+ def get_window_extent(self, renderer):
+ bbox = self.get_datalim(transforms.IdentityTransform())
+ #TODO:check to ensure that this does not fail for
+ #cases other than scatter plot legend
+ return bbox
+
def _prepare_points(self):
"""Point prep for drawing and hit testing"""
@@ -413,7 +419,19 @@
else:
self._edgecolors = self.to_rgba(self._A, self._alpha)
+ def update_from(self, other):
+ 'copy properties from other to self'
+ artist.Artist.update_from(self, other)
+ self._antialiaseds = other._antialiaseds
+ self._edgecolors_original = other._edgecolors_original
+ self._edgecolors = other._edgecolors
+ self._facecolors_original = other._facecolors_original
+ self._facecolors = other._facecolors
+ self._linewidths = other._linewidths
+ self._linestyles = other._linestyles
+ self._pickradius = other._pickradius
+
# these are not available for the object inspector until after the
# class is built so we define an initial set here for the init
# function and they will be overridden after object defn
@@ -702,7 +720,16 @@
def get_paths(self):
return self._paths
+ def get_numsides(self):
+ return len(self._paths[0])
+ def update_from(self, other):
+ Collection.update_from(self, other)
+
+ self._sizes = other._sizes
+ self._paths = other._paths
+ self._rotation = other._rotation
+
class StarPolygonCollection(RegularPolyCollection):
"""
Draw a collection of regular stars with *numsides* points."""
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel