Dear yt users,
I’m trying to write a script to create different multi-grid figures with in each the slice plot of one quantity from different snapshots (e.g. density slice for the snapshot from 1 to 4, see example below).
density_snapshot_1 | density_snapshot_2 ________________ |_________________ | density_snapshot_3 | density_snapshot_4
I’m able to do it looping first over the quantities and for each open the snapshots, but in they way I’m reopening the snapshots several times (i.e. the number of quantities I want to plot).
I think that the smart way of doing it is to have the for loops as below. My problem is that I need to create and save the figures at the "same time" and not one after the other.
I tried several option using the ‘field’ index, but I end up saving only the last ‘field’ figure.
snapshots = ['./snapshot_001','./snapshot_002','./snapshot_003','./snapshot_004’] fields = [‘density’, ‘velocity’, ’temperature’]
for i, snapshot in enumerate(snapshots): ds = yt.GadgetDataset(fn, unit_base=unit_base, bounding_box=bbox) # load data
for j, field in enumerate(fields): p = yt.SlicePlot(ds, 'z', field, center="center", width=2) p.set_cmap(field, "gist_rainbow")
# This forces the SlicePlot to redraw itself on the AxesGrid axes. # need to differentiate between figures using j index here plot = p.plots[field] plot.figure = plt.figure() plot.axes = grid[i].axes plot.cax = grid.cbar_axes[i]
# Finally, this actually redraws the plot. p._setup_plots()
for j, field in enumerate(fields): #need to call the different figures with j index here plt.savefig(field +’_evolution.png')
_______________________________________________ yt-users mailing list email@example.com http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org