import matplotlib.pyplot as plt1from mpl_toolkits.axes_grid1 import AxesGrid23import yt45fn = "IsolatedGalaxy/galaxy0030/galaxy0030"6ds = yt.load(fn) # load data78fig = plt.figure()910# See http://matplotlib.org/mpl_toolkits/axes_grid/api/axes_grid_api.html11# These choices of keyword arguments produce a four panel plot that includes12# four narrow colorbars, one for each plot. Axes labels are only drawn on the13# bottom left hand plot to avoid repeating information and make the plot less14# cluttered.15grid = AxesGrid(16fig,17(0.075, 0.075, 0.85, 0.85),18nrows_ncols=(2, 2),19axes_pad=1.0,20label_mode="1",21share_all=True,22cbar_location="right",23cbar_mode="each",24cbar_size="3%",25cbar_pad="0%",26)2728fields = [29("gas", "density"),30("gas", "velocity_x"),31("gas", "velocity_y"),32("gas", "velocity_magnitude"),33]3435# Create the plot. Since SlicePlot accepts a list of fields, we need only36# do this once.37p = yt.SlicePlot(ds, "z", fields)3839# Velocity is going to be both positive and negative, so let's make these40# slices use a linear colorbar scale41p.set_log(("gas", "velocity_x"), False)42p.set_log(("gas", "velocity_y"), False)4344p.zoom(2)4546# For each plotted field, force the SlicePlot to redraw itself onto the AxesGrid47# axes.48for i, field in enumerate(fields):49plot = p.plots[field]50plot.figure = fig51plot.axes = grid[i].axes52plot.cax = grid.cbar_axes[i]5354# Finally, redraw the plot on the AxesGrid axes.55p.render()5657plt.savefig("multiplot_2x2.png")585960