[yt-users] Custom made annotations on a slice plot

Nathan Goldbaum nathan12343 at gmail.com
Mon Sep 16 20:44:08 PDT 2013


Hi Roberto,

All plot window plots (e.g. SlicePlot, ProjectionPlot and friends) expose
the underlying matplotlib figure and axes like so:

slc = SlicePlot(pf, 0, 'Density')
plot = slc.plots['Density']

# mpl figure
fig = plot.figure

# mpl axes
ax = plot.axes

Using these objects, you can call arbitrary matplotlib functions that hang
off these objects.  For example:

from matplotlib.patches import Ellipse
el = Ellipse((0,0), .1, .2, angle=30, facecolor='none', edgecolor='black')
ax.add_artist(Ellipse)

Keep in mind that the coordinates I'm using for the Ellipse object are
relative to the plot's coordinates (i.e. they will be in the same units as
the x and y axis labels).

If you're feeling adventurous, you could try adding a new plot callback
that does this in general for any plot window plot.  The source code for
the callbacks are in
$YT_DEST/src/yt-hg/yt/visualization/plot_modifications.py.  You could
compare with the CircleCallback.

I've put together a notebook that demonstrates this.  You can view it here:
http://nbviewer.ipython.org/url/hub.yt-project.org/notebooks/bcd7d3592d49496f84827abb86a738da.ipynb

HTH,

Nathan


On Mon, Sep 16, 2013 at 6:51 PM, trobolo dinni <
trobolo.trobolo.dinni5 at gmail.com> wrote:

> Dear yt mailing list,
>
> I would like to ask a question about the annotations on the slice plots
> since I was unable to find a solution or any clue about it in the mailing
> list and the documentation.
>
> I selected an ellipsoid region of my simulation through the
> "pf.h.ellipsoid" container, this region has particular properties and I
> would like to highlight it in a density slice plot by by annotating the
> contour of the ellipsoid (resulting in an image similar to those obtained
> by annotating a sphere, but with the ellipse instead).
>
> Is there a way to achieve this result?
>
> Thanks,
>                   Roberto
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130916/cb323a93/attachment.htm>


More information about the yt-users mailing list