import numpy as np1from matplotlib.colors import LogNorm23import yt4from yt.visualization.api import get_multi_plot56fn = "Enzo_64/RD0006/RedshiftOutput0006" # dataset to load78# load data and get center value and center location as maximum density location9ds = yt.load(fn)10v, c = ds.find_max(("gas", "density"))1112# set up our Fixed Resolution Buffer parameters: a width, resolution, and center13width = (1.0, "unitary")14res = [1000, 1000]15# get_multi_plot returns a containing figure, a list-of-lists of axes16# into which we can place plots, and some axes that we'll put17# colorbars.1819# it accepts: # of x-axis plots, # of y-axis plots, and how the20# colorbars are oriented (this also determines where they go: below21# in the case of 'horizontal', on the right in the case of22# 'vertical'), bw is the base-width in inches (4 is about right for23# most cases)2425orient = "horizontal"26fig, axes, colorbars = get_multi_plot(2, 3, colorbar=orient, bw=6)2728# Now we follow the method of "multi_plot.py" but we're going to iterate29# over the columns, which will become axes of slicing.30plots = []31for ax in range(3):32sli = ds.slice(ax, c[ax])33frb = sli.to_frb(width, res)34den_axis = axes[ax][0]35temp_axis = axes[ax][1]3637# here, we turn off the axes labels and ticks, but you could38# customize further.39for ax in (den_axis, temp_axis):40ax.xaxis.set_visible(False)41ax.yaxis.set_visible(False)4243# converting our fixed resolution buffers to NDarray so matplotlib can44# render them45dens = np.array(frb["gas", "density"])46temp = np.array(frb["gas", "temperature"])4748plots.append(den_axis.imshow(dens, norm=LogNorm()))49plots[-1].set_clim((5e-32, 1e-29))50plots[-1].set_cmap("bds_highcontrast")5152plots.append(temp_axis.imshow(temp, norm=LogNorm()))53plots[-1].set_clim((1e3, 1e8))54plots[-1].set_cmap("hot")5556# Each 'cax' is a colorbar-container, into which we'll put a colorbar.57# the zip command creates triples from each element of the three lists58# . Note that it cuts off after the shortest iterator is exhausted,59# in this case, titles.60titles = [61r"$\mathrm{density}\ (\mathrm{g\ cm^{-3}})$",62r"$\mathrm{temperature}\ (\mathrm{K})$",63]64for p, cax, t in zip(plots, colorbars, titles):65# Now we make a colorbar, using the 'image' we stored in plots66# above. note this is what is *returned* by the imshow method of67# the plots.68cbar = fig.colorbar(p, cax=cax, orientation=orient)69cbar.set_label(t)7071# And now we're done!72fig.savefig(f"{ds}_3x2.png")737475