From: <lee...@us...> - 2010-06-12 16:07:50
|
Revision: 8418 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8418&view=rev Author: leejjoon Date: 2010-06-12 16:07:42 +0000 (Sat, 12 Jun 2010) Log Message: ----------- Fix markerscale and scatterpoints keyword arguments in legend. Thanks to Erik Tollerud Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/legend.py Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2010-06-12 07:48:54 UTC (rev 8417) +++ trunk/matplotlib/lib/matplotlib/legend.py 2010-06-12 16:07:42 UTC (rev 8418) @@ -53,9 +53,9 @@ bbox = self.legend.get_bbox_to_anchor() _bbox_transform = BboxTransformFrom(bbox) self.legend._loc = tuple(_bbox_transform.transform_point(loc_in_canvas)) - + class Legend(Artist): """ Place a legend on the axes at location loc. Labels are a @@ -256,7 +256,7 @@ self._scatteryoffsets = np.array([3./8., 4./8., 2.5/8.]) else: self._scatteryoffsets = np.asarray(scatteryoffsets) - reps = int(self.numpoints / len(self._scatteryoffsets)) + 1 + reps = int(self.scatterpoints / len(self._scatteryoffsets)) + 1 self._scatteryoffsets = np.tile(self._scatteryoffsets, reps)[:self.scatterpoints] # _legend_box is an OffsetBox instance that contains all @@ -519,6 +519,9 @@ legline_marker.set_clip_box(None) legline_marker.set_clip_path(None) legline_marker.set_linestyle('None') + if self.markerscale !=1: + newsz = legline_marker.get_markersize()*self.markerscale + legline_marker.set_markersize(newsz) # we don't want to add this to the return list because # the texts and handles are assumed to be in one-to-one # correpondence. @@ -554,11 +557,8 @@ #ydata = self._scatteryoffsets ydata = height*self._scatteryoffsets - size_max, size_min = max(handle.get_sizes()),\ - min(handle.get_sizes()) - # we may need to scale these sizes by "markerscale" - # attribute. But other handle types does not seem - # to care about this attribute and it is currently ignored. + size_max, size_min = max(handle.get_sizes())*self.markerscale**2,\ + min(handle.get_sizes())*self.markerscale**2 if self.scatterpoints < 4: sizes = [.5*(size_max+size_min), size_max, size_min] @@ -582,11 +582,8 @@ ydata = height*self._scatteryoffsets - size_max, size_min = max(handle.get_sizes()),\ - min(handle.get_sizes()) - # we may need to scale these sizes by "markerscale" - # attribute. But other handle types does not seem - # to care about this attribute and it is currently ignored. + size_max, size_min = max(handle.get_sizes())*self.markerscale**2,\ + min(handle.get_sizes())*self.markerscale**2 if self.scatterpoints < 4: sizes = [.5*(size_max+size_min), size_max, size_min] @@ -937,7 +934,7 @@ * True : turn draggable on * False : turn draggable off - + If draggable is on, you can drag the legend on the canvas with the mouse. The DraggableLegend helper instance is returned if draggable is on. @@ -947,7 +944,7 @@ # if state is None we'll toggle if state is None: state = not is_draggable - + if state: if self._draggable is None: self._draggable = DraggableLegend(self, use_blit) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |