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

Nathan Goldbaum nathan12343 at gmail.com
Tue Oct 28 21:26:33 PDT 2014


There are several examples starting here in the cookbook:

http://yt-project.org/doc/cookbook/complex_plots.html#multipanel-with-axes-labels

On Tue, Oct 28, 2014 at 9:09 PM, Rick Sarmento <rsarment at asu.edu> wrote:

> 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
>
>
>
> _______________________________________________
> 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/20141028/42b2f052/attachment.htm>


More information about the yt-users mailing list