
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? 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". Thanks! -Jeremy

On Sat, May 3, 2014 at 8:53 PM, Jeremy Ritter <jritter@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-...
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@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Forgot to mention that there's a bug related to how PhasePlot uses display_name in 2.6. I've fixed it in this pull request, which I expect to be accepted quickly: https://bitbucket.org/yt_analysis/yt/pull-request/873/fixing-an-issue-with-p... On Sat, May 3, 2014 at 9:31 PM, Nathan Goldbaum <nathan12343@gmail.com>wrote:
On Sat, May 3, 2014 at 8:53 PM, Jeremy Ritter <jritter@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-...
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@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (2)
-
Jeremy Ritter
-
Nathan Goldbaum