Scatter plot with a specific size per point

hi,

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.

Thanks for any pointer,

Matthieu

···


Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher

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

Indeed, a little bit less simple, but the solution nonetheless.

Thank you!

2012/3/26 Zachary Pincus <zachary.pincus@…1927…>

···

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


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


Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher

I needed something similar a while back, and Jae-Joon Lee helped me find a decent solution. Here’re the results for square markers:

···

On Mon, Mar 26, 2012 at 8:26 AM, Matthieu Brucher <matthieu.brucher@…287…> wrote:

Indeed, a little bit less simple, but the solution nonetheless.

Thank you!

2012/3/26 Zachary Pincus <zachary.pincus@…1927…>

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


#~~~

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.

Best,

-Tony