Hi together, I would like to relabel the y-axis of a profile plot. I tried the “set_ylabel”-command but got the error message that ProfilePlot does not have this attribute. I also could not find an answer when skimming through the yt Cookbook. Can anyone help me with that? Thanks in advance! Regards, Katharina ------------------------------------------------------- Katharina Wollenberg PhD Student in Astronomy Zentrum für Astronomie der Universität Heidelberg (ZAH) Institute of Theoretical Astrophysics (ITA) Albert-Ueberle-Str. 2 69120 Heidelberg Germany
On Sat, Nov 12, 2016 at 9:37 AM, Katharina Wollenberg < k.wollenberg@stud.uni-heidelberg.de> wrote:
Hi together,
I would like to relabel the y-axis of a profile plot. I tried the “set_ylabel”-command but got the error message that ProfilePlot does not have this attribute. I also could not find an answer when skimming through the yt Cookbook.
Hi Katharina, You're right that ProfilePlot currently doesn't have an "easy" way to set the plot axes labels. Adding such a feature would be a reasonable thing to do as well as an easy first yt project if you're interested. If you're not interested, please feel free to file an issue with the feature request: https://bitbucket.org/yt_analysis/yt/issues/new As a workaround, you can access the matplotlib axes object and customize the plot from there using that interface. Here is a snippet that illustrates how to do this: plot = yt.ProfilePlot(ds.all_data(), ('gas', 'density'), ('gas', 'temperature')) ax = plot.axes[('gas', 'temperature')] ax.set_ylabel('my ylabel') plot.save() Note that the keys of the plot.axes dictionary are the full field tuples, not the field name of the field plotted along the y axis. It's a dictionary because you are allowed to pass more than one y field to ProfilePlot, which will make more than one plot. You might take a look at plot.axes.keys() to see what I mean. Hope that helps, Nathan
Can anyone help me with that? Thanks in advance!
Regards,
Katharina ------------------------------------------------------- Katharina Wollenberg PhD Student in Astronomy
Zentrum für Astronomie der Universität Heidelberg (ZAH) Institute of Theoretical Astrophysics (ITA) Albert-Ueberle-Str. 2 69120 Heidelberg Germany
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Nathan, thanks a lot! It works perfectly.
Adding such a feature would be a reasonable thing to do as well as an easy first yt project if you're interested. If you're not interested, please feel free to file an issue with the feature request:
https://bitbucket.org/yt_analysis/yt/issues/new <https://bitbucket.org/yt_analysis/yt/issues/new> I am happy to contribute at some point in the future. Currently, other things keep me busy. However, I am going to file an issue so that you have it on the record.
Regards, Katharina
On 12.11.2016, at 17:36, Nathan Goldbaum <nathan12343@gmail.com> wrote:
On Sat, Nov 12, 2016 at 9:37 AM, Katharina Wollenberg <k.wollenberg@stud.uni-heidelberg.de <mailto:k.wollenberg@stud.uni-heidelberg.de>> wrote: Hi together,
I would like to relabel the y-axis of a profile plot. I tried the “set_ylabel”-command but got the error message that ProfilePlot does not have this attribute. I also could not find an answer when skimming through the yt Cookbook.
Hi Katharina,
You're right that ProfilePlot currently doesn't have an "easy" way to set the plot axes labels. Adding such a feature would be a reasonable thing to do as well as an easy first yt project if you're interested. If you're not interested, please feel free to file an issue with the feature request:
https://bitbucket.org/yt_analysis/yt/issues/new <https://bitbucket.org/yt_analysis/yt/issues/new>
As a workaround, you can access the matplotlib axes object and customize the plot from there using that interface. Here is a snippet that illustrates how to do this:
plot = yt.ProfilePlot(ds.all_data(), ('gas', 'density'), ('gas', 'temperature')) ax = plot.axes[('gas', 'temperature')] ax.set_ylabel('my ylabel') plot.save()
Note that the keys of the plot.axes dictionary are the full field tuples, not the field name of the field plotted along the y axis. It's a dictionary because you are allowed to pass more than one y field to ProfilePlot, which will make more than one plot. You might take a look at plot.axes.keys() to see what I mean.
Hope that helps,
Nathan
Can anyone help me with that? Thanks in advance!
Regards,
Katharina ------------------------------------------------------- Katharina Wollenberg PhD Student in Astronomy
Zentrum für Astronomie der Universität Heidelberg (ZAH) Institute of Theoretical Astrophysics (ITA) Albert-Ueberle-Str. 2 69120 Heidelberg Germany
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org <mailto:yt-users@lists.spacepope.org> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org <http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org>
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org <mailto:yt-users@lists.spacepope.org> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org <http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org>
participants (3)
-
Katharina Wollenberg
-
Katharina Wollenberg
-
Nathan Goldbaum