[yt-users] change size of phase plot

Latif latifne at gmail.com
Tue Apr 15 09:58:41 PDT 2014


Hi Nathan,
Thank you!
 I am trying to make phase plot but wanted to change the axis labels and
fonts etc. It is very simple script and should have worked as I followed
the discussion on this thread.  My y-axis label command is simply being
ignored. Any thoughts on this?
 plot = PhasePlot(dd, "Density", "Temperature", "CellMassMsun",
                 weight_field=None, fractional=True)
ax = plot.plots['CellMassMsun'].axes
ax.set_ylabel(r'$\mathrm{Density [g/cm^{3}]}$')
plot.reset_plot()
plot.save()
Cheers
Latif



On Tue, Apr 15, 2014 at 6:53 PM, Nathan Goldbaum <nathan12343 at gmail.com>wrote:

> Hi Latif,
>
> Can you give a little more detail about the problem you're having.
>  Specifically, can you write a short script that isn't working for you?  If
> you see any traceback errors can you also paste the full traceback?
>
> -Nathan
>
>
> On Tue, Apr 15, 2014 at 9:16 AM, Latif <latifne at gmail.com> wrote:
>
>> Hi all,
>> I am still having the same problem which Stephanie pointed out. Label
>> setting is not working with the following version of YT. Any ideas what is
>> going wrong here?
>>
>> Version = 2.7-dev
>> Changeset = c03ad444c015
>> Thanks in advance,
>> Cheers
>> Latif
>>
>>
>>
>> On Tue, Jan 28, 2014 at 9:47 PM, Nathan Goldbaum <nathan12343 at gmail.com>wrote:
>>
>>> PR has been merged:
>>>
>>> https://bitbucket.org/yt_analysis/yt/pull-request/696/fixing-an-issue-with-_plot_valid-never/diff
>>>
>>> Thanks, Matt!
>>>
>>> On Tue, Jan 28, 2014 at 12:35 PM, Nathan Goldbaum <nathan12343 at gmail.com>
>>> wrote:
>>> > I'll be PRing into 2.7dev, so no worries - my working copy just
>>> > happened to be 3.0dev when I saw your e-mail.
>>> >
>>> > Once my patch is accepted, you'll probably need to revert the manual
>>> > change you made:
>>> >
>>> > $ hg revert --all
>>> >
>>> > And then update:
>>> >
>>> > $ yt update
>>> >
>>> > If you didn't revert the change, yt would print instructions on how to
>>> > update manually (to account for the local changes in your copy).
>>> >
>>> > I'll reply to this thread once the PR is accepted.
>>> >
>>> > -Nathan
>>> >
>>> > On Tue, Jan 28, 2014 at 12:28 PM, Stephanie Tonnesen <
>>> stonnes at gmail.com> wrote:
>>> >> Genius!  Yes, this did work.  I am running yt 2.7dev, so as you said,
>>> the
>>> >> line numbers were a bit different.  If you open a PR for this patch,
>>> when it
>>> >> gets accepted what gets updated?  More specifically, will it get
>>> added to
>>> >> *my* yt when I type yt update?
>>> >>
>>> >>
>>> >> On Tue, Jan 28, 2014 at 3:16 PM, Nathan Goldbaum <
>>> nathan12343 at gmail.com>
>>> >> wrote:
>>> >>>
>>> >>> It should be working.  You're actually directly manipulating the
>>> >>> matplotlib axes object so this has nothing to do with what has or
>>> >>> hasn't been implemented in yt.
>>> >>>
>>> >>> It looks like the issue is actually due to an oversight in the
>>> >>> implementation of PhasePlot._setup_plots().
>>> >>>
>>> >>> I've fixed it in my local copy by doing the following:
>>> >>>
>>> >>> diff -r ff7f35e02f27 yt/visualization/profile_plotter.py
>>> >>> --- a/yt/visualization/profile_plotter.py       Mon Jan 27 11:52:18
>>> 2014
>>> >>> -0500
>>> >>> +++ b/yt/visualization/profile_plotter.py       Tue Jan 28 12:13:42
>>> 2014
>>> >>> -0800
>>> >>> @@ -653,6 +653,7 @@
>>> >>>                    [ax.xaxis.label, ax.yaxis.label, cbax.yaxis.label]
>>> >>>                  for label in labels:
>>> >>>                      label.set_color(self._font_color)
>>> >>> +        self._plot_valid = True
>>> >>>
>>> >>>      def save(self, name=None, mpl_kwargs=None):
>>> >>>          r"""
>>> >>>
>>> >>>
>>> >>> This is in yt 3.0dev, so your line numbers may be slightly different
>>> >>> if you're running the yt 2.6.1 release.
>>> >>>
>>> >>> Let me know if that works for you and I'll open a PR for this patch.
>>> >>>
>>> >>> -Nathan
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> On Tue, Jan 28, 2014 at 11:55 AM, Stephanie Tonnesen <
>>> stonnes at gmail.com>
>>> >>> wrote:
>>> >>> > Hi Nathan,
>>> >>> >
>>> >>> > Thanks!  I am no longer getting a Key Error, but the commands are
>>> simply
>>> >>> > being ignored.  Has this axis functionality been added to
>>> PhasePlot?
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> > On Tue, Jan 28, 2014 at 1:00 PM, Nathan Goldbaum <
>>> nathan12343 at gmail.com>
>>> >>> > wrote:
>>> >>> >>
>>> >>> >> Hi Stephanie,
>>> >>> >>
>>> >>> >> Phase plots are keyed with the z axis name.  Try:
>>> >>> >>
>>> >>> >> ax = plot.plots['CellMassMsun'].axes
>>> >>> >>
>>> >>> >> -Nathan
>>> >>> >>
>>> >>> >> On Tue, Jan 28, 2014 at 7:09 AM, Stephanie Tonnesen <
>>> stonnes at gmail.com>
>>> >>> >> wrote:
>>> >>> >> > Hi John (and all users!),
>>> >>> >> >
>>> >>> >> > Thanks, this definitely worked!  Now I am trying to make my
>>> axes look
>>> >>> >> > a
>>> >>> >> > bit
>>> >>> >> > nicer.  I would like to change my y-axis label and rotate my
>>> x-axis
>>> >>> >> > ticklabels by 45 degrees or only print every other ticklabel.  I
>>> >>> >> > tried
>>> >>> >> > to
>>> >>> >> > use the directions from the SlicePlot example,
>>> >>> >> >
>>> >>> >> >
>>> >>> >> >
>>> http://yt-project.org/docs/dev/cookbook/simple_plots.html#showing-and-hiding-axes-labels-and-colorbars
>>> ,
>>> >>> >> >
>>> >>> >> > plot =
>>> >>> >> >
>>> >>> >> >
>>> >>> >> >
>>> PhasePlot(tracerp25,"Density","z-velocity",["CellMassMsun"],weight_field=None,fontsize=13)#,x_bounds=[3e-28,5e-23],y_bounds=[-7e7,1.2e8])
>>> >>> >> >
>>> >>> >> > plot.set_log("Density",True)
>>> >>> >> > plot.set_log("z-velocity",False)
>>> >>> >> > plot.set_zlim("CellMassMsun",1e4,1e9)
>>> >>> >> > plot.set_figure_size(3)
>>> >>> >> >
>>> >>> >> > ax = plot.plots['z-velocity'].axes
>>> >>> >> > ax.set_ylabel(r'z-velocity (10$8$ cm/s)')
>>> >>> >> > for label in ax.xaxis.get_ticklabels():
>>> >>> >> >     label.set_rotation(45)
>>> >>> >> >
>>> >>> >> > plot.save()
>>> >>> >> >
>>> >>> >> > but get an error message:
>>> >>> >> >
>>> >>> >> > ax = plot.plots['z-velocity'].axes
>>> >>> >> > KeyError: 'z-velocity'
>>> >>> >> >
>>> >>> >> > I get the same error if I use 'Density' on that line instead.
>>> >>> >> >
>>> >>> >> > Thanks in advance,
>>> >>> >> >
>>> >>> >> > Stephanie
>>> >>> >> >
>>> >>> >> >
>>> >>> >> >
>>> >>> >> > On Mon, Jan 27, 2014 at 11:31 AM, John ZuHone <
>>> jzuhone at gmail.com>
>>> >>> >> > wrote:
>>> >>> >> >>
>>> >>> >> >> Stephanie,
>>> >>> >> >>
>>> >>> >> >> So you don't have to wait for me to finish this, as a
>>> >>> >> >> workaround/hack
>>> >>> >> >> you
>>> >>> >> >> can do this:
>>> >>> >> >>
>>> >>> >> >> pf.field_info["Density"].take_log=True
>>> >>> >> >>
>>> >>> >> >> which should get you the result you want.
>>> >>> >> >>
>>> >>> >> >> Best,
>>> >>> >> >>
>>> >>> >> >> John
>>> >>> >> >>
>>> >>> >> >> On Jan 26, 2014, at 3:38 PM, Stephanie Tonnesen <
>>> stonnes at gmail.com>
>>> >>> >> >> wrote:
>>> >>> >> >>
>>> >>> >> >> Sweet!  Thanks!  (I really need to update more often and see
>>> what
>>> >>> >> >> new
>>> >>> >> >> cool
>>> >>> >> >> things I can do...)
>>> >>> >> >>
>>> >>> >> >> Stephanie
>>> >>> >> >>
>>> >>> >> >>
>>> >>> >> >> On Sun, Jan 26, 2014 at 3:34 PM, John ZuHone <
>>> jzuhone at gmail.com>
>>> >>> >> >> wrote:
>>> >>> >> >>>
>>> >>> >> >>> Hi Stephanie,
>>> >>> >> >>>
>>> >>> >> >>> Ah yes, this is a problem I encountered just on Friday. We
>>> haven't
>>> >>> >> >>> set
>>> >>> >> >>> up
>>> >>> >> >>> PhasePlot or ProfilePlot to allow you to choose what scaling
>>> the
>>> >>> >> >>> plot
>>> >>> >> >>> is in.
>>> >>> >> >>>
>>> >>> >> >>> Since I need it too, it was already on my todo list. So I'll
>>> do it
>>> >>> >> >>> tomorrow.
>>> >>> >> >>>
>>> >>> >> >>> Best,
>>> >>> >> >>>
>>> >>> >> >>> John
>>> >>> >> >>>
>>> >>> >> >>> On Jan 26, 2014, at 3:32 PM, Stephanie Tonnesen <
>>> stonnes at gmail.com>
>>> >>> >> >>> wrote:
>>> >>> >> >>>
>>> >>> >> >>> Hi John,
>>> >>> >> >>>
>>> >>> >> >>> Ah, okay!  Updating my yt made it work.  yt version 2.7-dev.
>>> >>> >> >>>
>>> >>> >> >>> EXCEPT that I can't get it to plot the Density on the x-axis
>>> in log
>>> >>> >> >>> space!
>>> >>> >> >>>
>>> >>> >> >>> alld = pf.h.all_data()
>>> >>> >> >>>
>>> >>> >> >>> tracerp25 = alld.cut_region(["grid['specific_scalar[0]'] >
>>> 0.5",
>>> >>> >> >>> "grid['z'] < 0.192","grid['z'] > -0.192","grid['cyl_RCode'] <
>>> >>> >> >>> 1.2"])
>>> >>> >> >>>
>>> >>> >> >>> plot =
>>> >>> >> >>>
>>> >>> >> >>>
>>> >>> >> >>>
>>> PhasePlot(tracerp25,"Density","z-velocity",["CellMassMsun"],weight_field=None,fontsize=30)
>>> >>> >> >>> plot.set_log("Density",True)
>>> >>> >> >>> plot.set_log("z-velocity",False)
>>> >>> >> >>> plot.set_zlim("CellMassMsun",1e3,1e9)
>>> >>> >> >>> plot.save()
>>> >>> >> >>>
>>> >>> >> >>> Any more advice?  Thanks!
>>> >>> >> >>>
>>> >>> >> >>> Stephanie
>>> >>> >> >>>
>>> >>> >> >>>
>>> >>> >> >>> On Sun, Jan 26, 2014 at 10:44 AM, John ZuHone <
>>> jzuhone at gmail.com>
>>> >>> >> >>> wrote:
>>> >>> >> >>>>
>>> >>> >> >>>> Hi Stephanie,
>>> >>> >> >>>>
>>> >>> >> >>>> What is your version of yt? PhasePlot is 2.6 and later.
>>> >>> >> >>>>
>>> >>> >> >>>> Best,
>>> >>> >> >>>>
>>> >>> >> >>>> John
>>> >>> >> >>>>
>>> >>> >> >>>> On Jan 26, 2014, at 10:42 AM, Stephanie Tonnesen
>>> >>> >> >>>> <stonnes at gmail.com>
>>> >>> >> >>>> wrote:
>>> >>> >> >>>>
>>> >>> >> >>>> Hi all,
>>> >>> >> >>>>
>>> >>> >> >>>> Just as a quick update, I tried to change to using
>>> >>> >> >>>>
>>> >>> >> >>>> plot =
>>> >>> >> >>>>
>>> >>> >> >>>>
>>> >>> >> >>>>
>>> PhasePlot(tracerp25,"Density","z-velocity",["CellMassSolar"],weight=None)
>>> >>> >> >>>> plot.save()
>>> >>> >> >>>>
>>> >>> >> >>>> and got an error:  name 'PhasePlot' is not defined.
>>> >>> >> >>>>
>>> >>> >> >>>> Thanks,
>>> >>> >> >>>>
>>> >>> >> >>>> Stephanie
>>> >>> >> >>>>
>>> >>> >> >>>>
>>> >>> >> >>>> On Fri, Jan 24, 2014 at 3:47 PM, Stephanie Tonnesen
>>> >>> >> >>>> <stonnes at gmail.com>
>>> >>> >> >>>> wrote:
>>> >>> >> >>>>>
>>> >>> >> >>>>> Hi all,
>>> >>> >> >>>>>
>>> >>> >> >>>>> I am trying to make my phase plots smaller so they can fit
>>> more
>>> >>> >> >>>>> nicely
>>> >>> >> >>>>> into a paper.  Alternatively, I would be fine with upping
>>> the
>>> >>> >> >>>>> font
>>> >>> >> >>>>> size so
>>> >>> >> >>>>> when I shrink them you can read the axes.  I found advise
>>> on how
>>> >>> >> >>>>> to
>>> >>> >> >>>>> do this
>>> >>> >> >>>>> for slices, but not for phase_objects.
>>> >>> >> >>>>>
>>> >>> >> >>>>> pc = PlotCollection(pf)
>>> >>> >> >>>>>
>>> >>> >> >>>>> tracerp25 = alld.cut_region(["grid['specific_scalar[0]'] >
>>> 0.5",
>>> >>> >> >>>>> "grid['z'] < 0.192","grid['z'] > -0.192","grid['cyl_RCode']
>>> <
>>> >>> >> >>>>> 1.2"])
>>> >>> >> >>>>>
>>> >>> >> >>>>>
>>> >>> >> >>>>>
>>> >>> >> >>>>>
>>> >>> >> >>>>>
>>> pc.add_phase_object(tracerp25,["Density","z-velocity","CellMassSolar"],weight=None,x_bins=50,y_bins=50,y_bounds
>>> >>> >> >>>>> = [-4e7,8e7],x_bounds=[5e-28,5e-23],x_log=True,y_log=False)
>>> >>> >> >>>>>
>>> >>> >> >>>>> Any help is much appreciated!
>>> >>> >> >>>>>
>>> >>> >> >>>>> Thanks,
>>> >>> >> >>>>>
>>> >>> >> >>>>> Stephanie
>>> >>> >> >>>>
>>> >>> >> >>>>
>>> >>> >> >>>> _______________________________________________
>>> >>> >> >>>> yt-users mailing list
>>> >>> >> >>>> yt-users at lists.spacepope.org
>>> >>> >> >>>>
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >> >>>>
>>> >>> >> >>>>
>>> >>> >> >>>>
>>> >>> >> >>>> _______________________________________________
>>> >>> >> >>>> yt-users mailing list
>>> >>> >> >>>> yt-users at lists.spacepope.org
>>> >>> >> >>>>
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >> >>>>
>>> >>> >> >>>
>>> >>> >> >>> _______________________________________________
>>> >>> >> >>> yt-users mailing list
>>> >>> >> >>> yt-users at lists.spacepope.org
>>> >>> >> >>>
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >> >>>
>>> >>> >> >>>
>>> >>> >> >>>
>>> >>> >> >>> _______________________________________________
>>> >>> >> >>> yt-users mailing list
>>> >>> >> >>> yt-users at lists.spacepope.org
>>> >>> >> >>>
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >> >>>
>>> >>> >> >>
>>> >>> >> >> _______________________________________________
>>> >>> >> >> yt-users mailing list
>>> >>> >> >> yt-users at lists.spacepope.org
>>> >>> >> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >> >>
>>> >>> >> >>
>>> >>> >> >>
>>> >>> >> >> _______________________________________________
>>> >>> >> >> yt-users mailing list
>>> >>> >> >> yt-users at lists.spacepope.org
>>> >>> >> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >> >>
>>> >>> >> >
>>> >>> >> >
>>> >>> >> > _______________________________________________
>>> >>> >> > yt-users mailing list
>>> >>> >> > yt-users at lists.spacepope.org
>>> >>> >> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >> >
>>> >>> >> _______________________________________________
>>> >>> >> yt-users mailing list
>>> >>> >> yt-users at lists.spacepope.org
>>> >>> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> > _______________________________________________
>>> >>> > yt-users mailing list
>>> >>> > yt-users at lists.spacepope.org
>>> >>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>> >
>>> >>> _______________________________________________
>>> >>> yt-users mailing list
>>> >>> yt-users at lists.spacepope.org
>>> >>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> yt-users mailing list
>>> >> yt-users at lists.spacepope.org
>>> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>
>>
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
> _______________________________________________
> 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/20140415/ea66f8aa/attachment.html>


More information about the yt-users mailing list