[yt-users] Side-by-side Phase Plots
Rick Sarmento
rsarment at asu.edu
Wed Nov 5 07:17:50 PST 2014
Thanks a lot Nathan … I think I can make due by generating separate plots and then pasting them together manually.
Good to know that it wasn’t something dumb I was doing :)
Cheers!
Rick Sarmento
SESE Astronomy/Astrophysics Grad Student
rsarment at asu.edu
> On Nov 4, 2014, at 11:34 PM, Nathan Goldbaum <nathan12343 at gmail.com> wrote:
>
> Hey Rick,
>
> On Tue, Nov 4, 2014 at 9:21 PM, Rick Sarmento <rsarment at asu.edu <mailto:rsarment at asu.edu>> wrote:
>
>
> Hello all,
>
> I’m having trouble getting yt to plot 2 gas-phase diagrams side-by-side in a grid. I can do this fine for a projection plot, phase plots seems to behave differently. Here’s the code — any idea how to get these two plots side by side sharing the same scale/color-bar?
>
> # fractional=True keyword -- divide the profile data by the sum.
> fns = [ "/Users/earnric/RAMSES-Data/coolingFixedTau/output_00010/info_00010.txt",
> "/Users/earnric/RAMSES-Data/noCool/output_00010/info_00010.txt"]
>
> fig = plt.figure()
> grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
> nrows_ncols = (1, 2),
> axes_pad = 0.05,
> label_mode = "L",
> share_all = True,
> cbar_location="right",
> cbar_mode="single",
> cbar_size="3%",
> cbar_pad="0%")
> fig.suptitle("Gas Phase")
>
> for i, fn in enumerate(fns):
> ds = yt.load(fn)
> ad = ds.all_data()
> p = yt.PhasePlot(ad, "density", "temperature", "cell_mass", x_bins=256, y_bins=256, weight_field=None, fractional=True )
> plot = p.plots['cell_mass']
> if i % 2 == 0:
> ptype = "Gas phase ${H_2}$ cooling "
> else:
> ptype = "Gas phase Standard cooling "
> zStr = ptype + "z = %.1f" % ds.current_redshift
> plot.figure = fig
> plot.axes = grid[i].axes
> plot.cax = grid.cbar_axes[i]
> #plot.annotate_title(zStr) # YOU HAVE TO DO THIS AFTER THE AXES calls
>
> p['cell_mass'].axes.set_ylim (1e-1, 1e6)
> p['cell_mass'].axes.set_xlim (1e-29, 1e-24)
> p['cell_mass'].axes.set_title(zStr, fontsize=20)
> p.show()
>
> FWIW, this is the first I've ever heard someone trying to do this. I can confirm that it doesn't work.
>
> I tried experimenting a bit and unfortunately I think you're running into a limitation of matplotlib: AxesGrid doesn't support logarithmic x and y axes.
>
> I can get something sort of sensible if I specify linear x and y axes and manually adjust the aspect ratio, but I don't think this is a particularly sustainable solution for supporting these sorts of plots:
>
> http://nbviewer.ipython.org/gist/ngoldbaum/ab71b48bd42e8c2a5b42 <http://nbviewer.ipython.org/gist/ngoldbaum/ab71b48bd42e8c2a5b42>
>
> Unfortunately when I try to make the same plot using logarithmic axes, I get junk:
>
> http://nbviewer.ipython.org/gist/ngoldbaum/821e44612f53eae830d8 <http://nbviewer.ipython.org/gist/ngoldbaum/821e44612f53eae830d8>
>
> I think the most straightforward way to do this would be to do it 100% manually (outside of PhasePlot) using a Profile2D object and matplotlib. If you figure out something that works for you I think it would be a good addition for the cookbook.
>
> It might be possible to use PhasePlot with a hand-constructured set of axes, but I've never tried to set that up so I'm not sure if you'll need to modify yt to get it to work.
>
> Sorry I don't have better news for you - good luck with getting this plot working.
>
> -Nathan
>
>
>
> Cheers,
>
> Rick Sarmento
>
>
>
>
>
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org <mailto:yt-users at 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 at lists.spacepope.org <mailto:yt-users at lists.spacepope.org>
> http://lists.spacepope.org/listinfo.cgi/yt-users-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/20141105/7101d1da/attachment.htm>
More information about the yt-users
mailing list