[yt-users] Drawing order of plot annotations

Nathan Goldbaum nathan12343 at gmail.com
Mon May 16 12:43:03 PDT 2016


Hi Dan,

Callbacks are run in the order they are called.

That said, even if you run the callbacks in the correct order, you will
still see a circle on top of the contours due to the way matplotlib handles
things that need to be drawn on top of other things. The way to fix this is
to pass "zorder" to matplotlib. Here's an example using a public dataset
from yt-project.org/data:

    import yt

    ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')

    plot = yt.SlicePlot(ds, 2, 'density')

    plot.annotate_contour('density', plot_args={'zorder': 1})
    plot.annotate_sphere(ds.domain_center, (100, 'kpc'),
circle_args={'color': 'white', 'zorder': 2})

Here "plot_args" and "circle_args" are passed directly to matplotlib, so
they allow you to pass keyword arguments to matplotlib's drawing functions
that wouldn't otherwise get passed in by yt.

Hope that's helpful,

Nathan

On Mon, May 16, 2016 at 1:40 PM, Daniel Fenn <dsfenn at gmail.com> wrote:

> Hi,
>
> Is it possible to control the order that plot annotations are drawn? For
> example, right now I'm plotting density contours, and I'd like to add a
> circle annotation on top. However, when I add the circle, it's drawn behind
> the density contours. This happens no matter the order that I add the
> annotations in my script.
>
> Is there a straightforward way to force the circle to be drawn on top of
> the density contours, so that it's not obscured?
>
> Thanks,
>
> Dan
>
> _______________________________________________
> 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/20160516/1c8f18f8/attachment.html>


More information about the yt-users mailing list