On Mon, Mar 26, 2012 at 8:26 AM, Matthieu Brucher <
matthieu.bruc...@gmail.com> wrote:
> Indeed, a little bit less simple, but the solution nonetheless.
>
> Thank you!
>
>
> 2012/3/26 Zachary Pincus <zachary.pin...@yale.edu>
>
>> > I'd like to display a scatter plot where the size for each element is
>> fixed. Currently, when I modify the size of the figure, the size of a
>> marker is fixed, and I would like it to be proportional to the window.
>> > I want this because the size of the marker indicates an extent, and I
>> would like it to confirm that the extents correctly cover the other points.
>>
>> If it's truly an extent, you might be better off drawing polygons of the
>> extent boundaries in the graph's coordinate system -- then things will
>> scale as you desire. This will require digging down a bit into the object
>> API -- make a new matplotlib.collections.PolyCollection (or
>> RegularPolyCollection), and add it to your axes with Axes.add_collection().
>>
>> Zach
>> ---------------------------------------------------------------------
>
>
I needed something similar a while back, and Jae-Joon Lee helped me find a
decent solution. Here're the results for square markers:
#~~~
import matplotlib.collections as collections
import matplotlib.transforms as transforms
class SquareCollection(collections.RegularPolyCollection):
"""Return a collection of squares."""
def __init__(self, **kwargs):
super(SquareCollection, self).__init__(4, rotation=np.pi/4.,
**kwargs)
def get_transform(self):
"""Return transform scaling circle areas to data space."""
ax = self.axes
pts2pixels = 72.0 / ax.figure.dpi
scale_x = pts2pixels * ax.bbox.width / ax.viewLim.width
scale_y = pts2pixels * ax.bbox.height / ax.viewLim.height
return transforms.Affine2D().scale(scale_x, scale_y)
#~~~
Example
use<https://github.com/tonysyu/mpltools/blob/master/mpltools/special/hinton.py>
.
Best,
-Tony
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users