[yt-svn] commit/yt-doc: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Dec 10 11:48:24 PST 2013
4 new commits in yt-doc:
https://bitbucket.org/yt_analysis/yt-doc/commits/150c2e8fd1a8/
Changeset: 150c2e8fd1a8
User: ngoldbaum
Date: 2013-12-05 06:18:26
Summary: Adding a new multipanel recipe.
Affected #: 2 files
diff -r f5100120a4f12dd26cdd5371375f87df6c7458bc -r 150c2e8fd1a8cb7a4fe0a13e018a6f86edc72c12 source/cookbook/complex_plots.rst
--- a/source/cookbook/complex_plots.rst
+++ b/source/cookbook/complex_plots.rst
@@ -29,6 +29,15 @@
.. yt_cookbook:: multiplot_2x2_time_series.py
+Mutiple Slice Multipanel
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+This illustrates how to create a multipanel plot of slices along the coordinate
+axes. To focus on what's happening in the x-y plane, we make an additional
+Temperature slice for the bottom-right subpanel.
+
+.. yt-cookbook:: multiplot_2x2_coordaxes_slice.py
+
Multi-Plot Slice and Projections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff -r f5100120a4f12dd26cdd5371375f87df6c7458bc -r 150c2e8fd1a8cb7a4fe0a13e018a6f86edc72c12 source/cookbook/multiplot_2x2_coordaxes_slice.py
--- /dev/null
+++ b/source/cookbook/multiplot_2x2_coordaxes_slice.py
@@ -0,0 +1,35 @@
+from yt.mods import *
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid1 import AxesGrid
+
+fn = "IsolatedGalaxy/galaxy0030/galaxy0030"
+pf = load(fn) # load data
+
+fig = plt.figure()
+grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
+ nrows_ncols = (2, 2),
+ axes_pad = 1.0,
+ label_mode = "all",
+ share_all = True,
+ cbar_location="right",
+ cbar_mode="edge",
+ cbar_size="5%",
+ cbar_pad="0%")
+
+cuts = ['x', 'y', 'z', 'z']
+fields = ['Density', 'Density', 'Density', 'Temperature']
+plots = []
+
+for i, (direction, field) in enumerate(zip(cuts, fields)):
+ p = SlicePlot(pf, direction, field)
+ p.zoom(40)
+ plot = p.plots[field]
+ plot.figure = fig
+ plot.axes = grid[i].axes
+ if field == 'Density':
+ plot.cax = grid.cbar_axes[0]
+ elif field == 'Temperature':
+ plot.cax = grid.cbar_axes[1]
+ p._setup_plots()
+
+plt.savefig('multiplot_2x2_coordaxes_slice.png')
https://bitbucket.org/yt_analysis/yt-doc/commits/9b97f69fafe0/
Changeset: 9b97f69fafe0
User: ngoldbaum
Date: 2013-12-05 06:21:11
Summary: Removing an unused variable.
Affected #: 1 file
diff -r 150c2e8fd1a8cb7a4fe0a13e018a6f86edc72c12 -r 9b97f69fafe0a884ad871002fc934b989073aa63 source/cookbook/multiplot_2x2_coordaxes_slice.py
--- a/source/cookbook/multiplot_2x2_coordaxes_slice.py
+++ b/source/cookbook/multiplot_2x2_coordaxes_slice.py
@@ -18,7 +18,6 @@
cuts = ['x', 'y', 'z', 'z']
fields = ['Density', 'Density', 'Density', 'Temperature']
-plots = []
for i, (direction, field) in enumerate(zip(cuts, fields)):
p = SlicePlot(pf, direction, field)
https://bitbucket.org/yt_analysis/yt-doc/commits/6cf80a38a235/
Changeset: 6cf80a38a235
User: ngoldbaum
Date: 2013-12-10 05:12:58
Summary: Add comments for all of the multiplot recipes.
Affected #: 3 files
diff -r 9b97f69fafe0a884ad871002fc934b989073aa63 -r 6cf80a38a23580a781165144b76bb4de4f78b305 source/cookbook/multiplot_2x2.py
--- a/source/cookbook/multiplot_2x2.py
+++ b/source/cookbook/multiplot_2x2.py
@@ -6,6 +6,12 @@
pf = load(fn) # load data
fig = plt.figure()
+
+# See http://matplotlib.org/mpl_toolkits/axes_grid/api/axes_grid_api.html
+# These choices of keyword arguments produce a four panel plot that includes
+# four narrow colorbars, one for each plot. Axes labels are only drawn on the
+# bottom left hand plot to avoid repeating information and make the plot less
+# cluttered.
grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
nrows_ncols = (2, 2),
axes_pad = 1.0,
@@ -18,14 +24,20 @@
fields = ['Density', 'x-velocity', 'y-velocity', 'VelocityMagnitude']
+# Create the plot. Since SlicePlot accepts a list of fields, we need only
+# do this once.
p = SlicePlot(pf, 'z', fields)
p.zoom(2)
+# For each plotted field, force the SlicePlot to redraw itself onto the AxesGrid
+# axes.
for i, field in enumerate(fields):
plot = p.plots[field]
plot.figure = fig
plot.axes = grid[i].axes
plot.cax = grid.cbar_axes[i]
+# Finally, redraw the plot on the AxesGrid axes.
p._setup_plots()
+
plt.savefig('multiplot_2x2.png')
diff -r 9b97f69fafe0a884ad871002fc934b989073aa63 -r 6cf80a38a23580a781165144b76bb4de4f78b305 source/cookbook/multiplot_2x2_coordaxes_slice.py
--- a/source/cookbook/multiplot_2x2_coordaxes_slice.py
+++ b/source/cookbook/multiplot_2x2_coordaxes_slice.py
@@ -6,6 +6,12 @@
pf = load(fn) # load data
fig = plt.figure()
+
+# See http://matplotlib.org/mpl_toolkits/axes_grid/api/axes_grid_api.html
+# These choices of keyword arguments produce a wide colorbar that is only drawn
+# on the right hand side. This means there are only two colorbar axes, one for
+# Density and another for Temperature. In addition, draw axes labels for all
+# plots.
grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
nrows_ncols = (2, 2),
axes_pad = 1.0,
@@ -20,15 +26,24 @@
fields = ['Density', 'Density', 'Density', 'Temperature']
for i, (direction, field) in enumerate(zip(cuts, fields)):
+ # Load the data and create a single plot
p = SlicePlot(pf, direction, field)
p.zoom(40)
+
+ # This forces the ProjectionPlot to redraw itself on the AxesGrid axes.
plot = p.plots[field]
plot.figure = fig
plot.axes = grid[i].axes
+
+ # Since there are only two colorbar axes, we need to make sure we don't try
+ # to set the temperature colorbar to cbar_axes[4], which would yield a plot
+ # without a temperature colorbar.
if field == 'Density':
plot.cax = grid.cbar_axes[0]
elif field == 'Temperature':
plot.cax = grid.cbar_axes[1]
+
+ # Finally, redraw the plot.
p._setup_plots()
plt.savefig('multiplot_2x2_coordaxes_slice.png')
diff -r 9b97f69fafe0a884ad871002fc934b989073aa63 -r 6cf80a38a23580a781165144b76bb4de4f78b305 source/cookbook/multiplot_2x2_time_series.py
--- a/source/cookbook/multiplot_2x2_time_series.py
+++ b/source/cookbook/multiplot_2x2_time_series.py
@@ -5,6 +5,12 @@
fns = ['Enzo_64/DD0005/data0005','Enzo_64/DD0015/data0015', 'Enzo_64/DD0025/data0025', 'Enzo_64/DD0035/data0035']
fig = plt.figure()
+
+# See http://matplotlib.org/mpl_toolkits/axes_grid/api/axes_grid_api.html
+# These choices of keyword arguments produce a four panel plot with a single
+# shared narrow colorbar on the right hand side of the multipanel plot. Axes
+# labels are drawn for all plots since we're slicing along different directions
+# for each plot.
grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
nrows_ncols = (2, 2),
axes_pad = 0.05,
@@ -16,13 +22,20 @@
cbar_pad="0%")
for i, fn in enumerate(fns):
+ # Load the data and create a single plot
pf = load(fn) # load data
p = ProjectionPlot(pf, 'z', 'Density', width=(55, 'Mpccm'))
+
+ # Ensure the colorbar limits match for all plots
p.set_zlim('Density', 1e-4, 1e-2)
+
+ # This forces the ProjectionPlot to redraw itself on the AxesGrid axes.
plot = p.plots['Density']
plot.figure = fig
plot.axes = grid[i].axes
plot.cax = grid.cbar_axes[i]
+
+ # Finally, this actually redraws the plot.
p._setup_plots()
plt.savefig('multiplot_2x2_time_series.png')
https://bitbucket.org/yt_analysis/yt-doc/commits/157faabb0916/
Changeset: 157faabb0916
User: ngoldbaum
Date: 2013-12-10 06:05:24
Summary: Touch up comments for multislice recipe.
Affected #: 1 file
diff -r 6cf80a38a23580a781165144b76bb4de4f78b305 -r 157faabb091612c5dbabce2c97ffafcc93759500 source/cookbook/multiplot_2x2_coordaxes_slice.py
--- a/source/cookbook/multiplot_2x2_coordaxes_slice.py
+++ b/source/cookbook/multiplot_2x2_coordaxes_slice.py
@@ -8,9 +8,9 @@
fig = plt.figure()
# See http://matplotlib.org/mpl_toolkits/axes_grid/api/axes_grid_api.html
-# These choices of keyword arguments produce a wide colorbar that is only drawn
-# on the right hand side. This means there are only two colorbar axes, one for
-# Density and another for Temperature. In addition, draw axes labels for all
+# These choices of keyword arguments produce two colorbars, both drawn on the
+# right hand side. This means there are only two colorbar axes, one for Density
+# and another for Temperature. In addition, axes labels will be drawn for all
# plots.
grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
nrows_ncols = (2, 2),
@@ -36,8 +36,10 @@
plot.axes = grid[i].axes
# Since there are only two colorbar axes, we need to make sure we don't try
- # to set the temperature colorbar to cbar_axes[4], which would yield a plot
- # without a temperature colorbar.
+ # to set the temperature colorbar to cbar_axes[4], which would if we used i
+ # to index cbar_axes, yielding a plot without a Temperature colorbar.
+ # This unecessarily redraws the Density colorbar three times, but that has
+ # no effect on the final plot.
if field == 'Density':
plot.cax = grid.cbar_axes[0]
elif field == 'Temperature':
Repository URL: https://bitbucket.org/yt_analysis/yt-doc/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list