[yt-users] More Plot title issues... ProjectionPlot on a grid

Rick Sarmento rsarment at asu.edu
Tue Oct 28 21:09:23 PDT 2014


While I’m on the subject of plot title … I’m trying to put two plots in a grid, side-by-side… using different RAMSES data files. I need to have titles/annotations on these to distinguish which one has H2 cooling turned on and which has it off… I’ve tried several API calls… with the results below… 

Anyone know how to do this? Also, what if I wanted a 2x2 grid of plots? 

fns = ["/Users/earnric/RAMSES-Data/cooling/output_00008/info_00008.txt",
       "/Users/earnric/RAMSES-Data/noCool/output_00008/info_00008.txt"]

fields = ["density","temperature"]

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 Temperature")

for i, fn in enumerate(fns):
    # Load the data and create a single plot
    ds = yt.load(fn) # load data
    p = yt.ProjectionPlot(ds, 'z', 'temperature', weight_field="density")

    # Ensure the colorbar limits match for all plots
    p.set_zlim('temperature', 0.1, 1e4)

    # This forces the ProjectionPlot to redraw itself on the AxesGrid axes.
    plot = p.plots['temperature']
    if i % 2 == 0:
        ptype = "Cooling "
    else:
        ptype = "No cooling "
    zStr = ptype + "z = %.1f" % ds.current_redshift 
    #p.annotate_title(zStr) # Doesn't work... bug
    plot.figure = fig
    plot.axes = grid[i].axes
    ##plot['temperature'].axes.set_title(zStr, fontsize=14) # Error
    ##plot.axes.set_title(zStr, fontsize=14) # NOTHING, but doesn't error
    ##plot.annotate_text(-7.0,10.0, zStr, **{'fontsize':20}) # Error
    plot.cax = grid.cbar_axes[i]
    plot.axes.set_title(zStr)

    # Finally, this actually redraws the plot.
    p._setup_plots()
p.show()

Thx again.

Cheers!

Rick Sarmento
SESE Astronomy/Astrophysics Grad Student
rsarment at asu.edu


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20141028/0813d5cf/attachment.htm>


More information about the yt-users mailing list