Skip to content

Commit 9870268

Browse files
committed
Allow passing through image and cbar axes in plot_bot
1 parent 961ed0b commit 9870268

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

dedalus/extras/plot_tools.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,21 @@ def plot_bot(dset, image_axes, data_slices, image_scales=(0,0), clim=None, even_
102102
fig = plt.figure(**figkw)
103103
axes = fig.add_subplot(1, 1, 1)
104104

105-
# Setup axes
106-
# Bounds (left, bottom, width, height) relative-to-axes
107-
pbbox = transforms.Bbox.from_bounds(0.03, 0, 0.94, 0.94)
108-
cbbox = transforms.Bbox.from_bounds(0.03, 0.95, 0.94, 0.05)
109-
# Convert to relative-to-figure
110-
to_axes_bbox = transforms.BboxTransformTo(axes.get_position())
111-
pbbox = pbbox.transformed(to_axes_bbox)
112-
cbbox = cbbox.transformed(to_axes_bbox)
113-
# Create new axes and suppress base axes
114-
paxes = axes.figure.add_axes(pbbox)
115-
caxes = axes.figure.add_axes(cbbox)
116-
axes.axis('off')
105+
if isinstance(axes, (list, tuple)):
106+
paxes, caxes = axes
107+
else:
108+
# Setup axes
109+
# Bounds (left, bottom, width, height) relative-to-axes
110+
pbbox = transforms.Bbox.from_bounds(0.03, 0, 0.94, 0.94)
111+
cbbox = transforms.Bbox.from_bounds(0.03, 0.95, 0.94, 0.05)
112+
# Convert to relative-to-figure
113+
to_axes_bbox = transforms.BboxTransformTo(axes.get_position())
114+
pbbox = pbbox.transformed(to_axes_bbox)
115+
cbbox = cbbox.transformed(to_axes_bbox)
116+
# Create new axes and suppress base axes
117+
paxes = axes.figure.add_axes(pbbox)
118+
caxes = axes.figure.add_axes(cbbox)
119+
axes.axis('off')
117120

118121
# Colormap options
119122
cmap = copy.copy(matplotlib.cm.get_cmap(cmap))

0 commit comments

Comments
 (0)