<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Dear yt users, </div><div class=""><br class=""></div><div class="">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).</div><div class=""><br class=""></div><div class="">density_snapshot_1 | density_snapshot_2 </div><div class="">________________ |_________________</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                              </span> |</div><div class="">density_snapshot_3 | density_snapshot_4</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">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).</div><div class=""><br class=""></div><div class="">I think that the smart way of doing it is to have the for loops as below. </div><div class="">My problem is that I need to create and save the figures at the "same time" and not one after the other. </div><div class=""><br class=""></div><div class="">I tried several option using the ‘field’ index, but I end up saving only the last ‘field’ figure. </div><div class=""><br class=""></div><div class="">Any suggestion?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Nicola Clementel</div><div class=""><br class=""></div><div class="">snapshots = ['./snapshot_001','./snapshot_002','./snapshot_003','./snapshot_004’]</div><div class="">fields = [‘density’, ‘velocity’, ’temperature’]</div><div class=""><br class=""></div><div class="">for i, snapshot in enumerate(snapshots):</div><div class="">    ds = yt.GadgetDataset(fn, unit_base=unit_base, bounding_box=bbox) # load data</div><div class=""><br class=""></div><div class="">    for j, field in enumerate(fields):</div><div class="">        p = yt.SlicePlot(ds, 'z', field, center="center", width=2)</div><div class="">        p.set_cmap(field, "gist_rainbow")</div><div class=""><br class=""></div><div class="">        # This forces the SlicePlot to redraw itself on the AxesGrid axes.</div><div class=""><b class=""><span class="Apple-tab-span" style="white-space:pre">       </span># need to differentiate between figures using j index here</b></div><div class="">        plot = p.plots[field]</div><div class="">        plot.figure = plt.figure()</div><div class="">        plot.axes = grid[i].axes</div><div class="">        plot.cax = grid.cbar_axes[i]</div><div class=""><br class=""></div><div class="">        # Finally, this actually redraws the plot.</div><div class="">        p._setup_plots()</div><div class=""><br class=""></div><div class="">for j, field in enumerate(fields):</div><div class="">   <b class=""> #need to call the different figures with j index here</b></div><div class="">    plt.savefig(field +’_evolution.png')</div></body></html>