From: Yannick Copin <yannick.copin@la...>  20100201 15:36:45
Attachments:
ellipseColl.py

Hi, I would like to plot lots of error ellipses on my plot. I thought I could use an EllipseCollection to do so, but I didn't manage to get the ellipse sizes, expressed in data units, right (see test script attached). When using a plain list of Ellipse's, everything looks fine: ells = [ P.matplotlib.patches.Ellipse(xy=xyi, width=wi, height=hi, angle=ai, edgecolor='b', facecolor='b', alpha=0.3) for xyi,wi,hi,ai in zip(xy,w,h,a)] for ell in ells: ax.add_artist(ell) But when using EllipseCollection (as explained in http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_collection.html), coll = P.matplotlib.collections.EllipseCollection(widths=w, heights=h, angles=a, units='x', offsets=xy, transOffset=ax.transData, edgecolor='r', facecolor='r', alpha=0.3) ax.add_collection(coll) the size of the ellipses (expressed in data units) appears incorrect, and depends furthermore of the aspect ratio of the figure (try pan/zoom or resize the interactive window). I naively thought the two approaches should give the same result... Did I miss something in the way to use EllipseCollections? Cheers,  .~. Yannick COPIN (o:>* Doctus cum libro /V\ Institut de physique nucleaire de Lyon (IN2P3  France) // \\ Tel: (33/0) 472 431 968 AIM: YnCopin ICQ: 236931013 /( )\ http://snovae.in2p3.fr/ycopin/ ^`~'^ 
From: Eric Firing <efiring@ha...>  20100201 18:15:41

Yannick Copin wrote: > Hi, > > I would like to plot lots of error ellipses on my plot. I thought I > could use an EllipseCollection to do so, but I didn't manage to get the > ellipse sizes, expressed in data units, right (see test script attached). > > When using a plain list of Ellipse's, everything looks fine: > > ells = [ P.matplotlib.patches.Ellipse(xy=xyi, > width=wi, height=hi, > angle=ai, > edgecolor='b', > facecolor='b', > alpha=0.3) > for xyi,wi,hi,ai in zip(xy,w,h,a)] > for ell in ells: > ax.add_artist(ell) > > But when using EllipseCollection (as explained in > http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_collection.html), > > > coll = P.matplotlib.collections.EllipseCollection(widths=w, > heights=h, > angles=a, > units='x', > offsets=xy, > transOffset=ax.transData, > edgecolor='r', > facecolor='r', > alpha=0.3) > ax.add_collection(coll) > > the size of the ellipses (expressed in data units) appears incorrect, > and depends furthermore of the aspect ratio of the figure (try pan/zoom > or resize the interactive window). Maybe I am misunderstanding, but the EllipseCollection in the example is panning and zooming as I expect. The shapes and orientations are staying the same while the scale expands and contracts with the xaxis. The problem is that the option you are looking for does not exist yet. I am not sure yet whether what you need is identical to an option I added to quiver (from which I partially derived EllipseCollection). I suspect it is. Do you want width to scale with x and height to scale with y? And the angle to scale such that a 45degree angle always corresponds to equal increments in x and in y, all in data units? > > I naively thought the two approaches should give the same result... Did > I miss something in the way to use EllipseCollections? EllipseCollection is derived more from quiver than from Ellipse. Eric 
From: Yannick Copin <yannick.copin@la...>  20100202 15:02:15

Eric Firing wrote: > Maybe I am misunderstanding, but the EllipseCollection in the example is > panning and zooming as I expect. The shapes and orientations are > staying the same while the scale expands and contracts with the xaxis. > > The problem is that the option you are looking for does not exist yet. > I am not sure yet whether what you need is identical to an option I > added to quiver (from which I partially derived EllipseCollection). I > suspect it is. Thanks, I now understand better what is the main goal of EllipseCollection: in a quiverlike use, you don't want indeed the plotted ellipses to change size and/or orientation with scaling and zooming. > Do you want width to scale with x and height to scale with y? And the > angle to scale such that a 45degree angle always corresponds to equal > increments in x and in y, all in data units? Yes, in the context of errorellipses, I would like to see my ellipses scale with x and y, as they do when I plot them individually as Ellipse patches (see example scripts, the blue ellipses are what I would like to obtain using an EllipseCollection), something like "units='data'" in EllipseCollection... Cheers,  .~. Yannick COPIN (o:>* Doctus cum libro /V\ Institut de physique nucleaire de Lyon (IN2P3  France) // \\ Tel: (33/0) 472 431 968 AIM: YnCopin ICQ: 236931013 /( )\ http://snovae.in2p3.fr/ycopin/ ^`~'^ 
From: Eric Firing <efiring@ha...>  20100202 16:43:53

Yannick Copin wrote: > Eric Firing wrote: >> Maybe I am misunderstanding, but the EllipseCollection in the example >> is panning and zooming as I expect. The shapes and orientations are >> staying the same while the scale expands and contracts with the xaxis. >> >> The problem is that the option you are looking for does not exist >> yet. I am not sure yet whether what you need is identical to an >> option I added to quiver (from which I partially derived >> EllipseCollection). I suspect it is. > > Thanks, I now understand better what is the main goal of > EllipseCollection: in a quiverlike use, you don't want indeed the > plotted ellipses to change size and/or orientation with scaling and > zooming. > >> Do you want width to scale with x and height to scale with y? And the >> angle to scale such that a 45degree angle always corresponds to equal >> increments in x and in y, all in data units? > > Yes, in the context of errorellipses, I would like to see my ellipses > scale with x and y, as they do when I plot them individually as Ellipse > patches (see example scripts, the blue ellipses are what I would like to > obtain using an EllipseCollection), something like "units='data'" in > EllipseCollection... I agree, this really is needed, and I will put it in ASAP. It may take a little while, though, so in the meantime you are stuck with the individual patches. Thanks for bringing it to my attention. Eric 