[yt-users] Axis labels and text annotations

Nathan Goldbaum nathan12343 at gmail.com
Sat May 3 21:31:29 PDT 2014


On Sat, May 3, 2014 at 8:53 PM, Jeremy Ritter
<jritter at astro.as.utexas.edu>wrote:

> Hello,
>
> I'm relatively new to YT. Creating great looking plots seems to be really
> easy, but setting axis labels and other text labels (timestamps) has proven
> to be quite challenging. I'm creating some phase plots with the latest
> stable version (2.6 I think), and I would like for variables to have proper
> names, e.g. "Number Density" instead of "NumberDensity".
>
> I first tried changing the labels using the axes object
> set_xlabel/set_ylabel methods, but that removes the units and doesn't
> accept latex style commands for making my own units. It also appears to
> change the font style.
>
> Then I tried creating derived fields with the proper names including
> spaces, but it seems that the labels get squished, having all spaces
> removed when it prints the label. Filename output still has the spaces in
> the variable name.


> What is the easiest way to set publication quality axis labels with units
> in v2.6?
>

Hi Jeremy,

This is cleaner in the upcoming 3.0 release, where we've rethought how
fields, units, and plot labels work.

In 2.6 you should be able to get what you want by supplying a custom
`display_name` when you call `add_field`.  See this page for more details
on keyword arguments accepted by add_field:

http://yt-project.org/docs/dev/analyzing/creating_derived_fields.html#field-options


>
> My other problem seems to be that I'm unable to use any of the annotation
> callbacks with a phase plot. Is this true? I just want to add a timestamp,
> for which I've already created the string, e.g. "5.35 Myr".
>
>
This wouldn't be too hard to add, but no one has done it yet.  We'd love
pull requests to enable plot callbacks for phase plots, which should be
relatively straightforward.  Plot callbacks for ProfilePlot would be harder
(since it shares less code with PlotWindow) but doable probably.

For now take a look at this example, which addresses both the points you
bring up:

http://nbviewer.ipython.org/gist/ngoldbaum/11510747

-Nathan

Thanks!
> -Jeremy
> _______________________________________________
> 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/20140503/71485b8c/attachment.htm>


More information about the yt-users mailing list