Insets and panels¶
Panel axes¶
It is common to need “panels” for plotting secondary 1-dimensional datasets or summary statistics along the sides of axes.
With ProPlot, you can generate “panels” using the panel
or panel_axes
commands. The axes returned by panels are instances of XYAxes
.
To generate “stacked” panels, call panel
or panel_axes
more than once. To include panels when centering spanning axis labels and super titles, pass includepanels=True
to Figure
.
[1]:
import proplot as plot
f, axs = plot.subplots(axwidth=1.2, nrows=2, ncols=2, share=0)
for ax, side in zip(axs, 'tlbr'):
ax.panel_axes(side)
axs.format(title='Title', suptitle='Panel axes demo', collabels=['Column 1', 'Column 2'],
abcloc='ul', titleloc='uc', xlabel='xlabel', ylabel='ylabel', abc=True, top=False)
axs.format(xlim=(0, 1), ylim=(0, 1),
ylocator=plot.arange(0.2, 0.8, 0.2),
xlocator=plot.arange(0.2, 0.8, 0.2))
[2]:
import proplot as plot
import numpy as np
state = np.random.RandomState(51423)
data = (state.rand(20, 20)-0.1).cumsum(axis=1)
f, axs = plot.subplots(axwidth=1.5, nrows=2, ncols=2,
share=0, panelpad=0.1, includepanels=True)
maxs = axs.panel('r', space=0)
saxs = axs.panel('r', space=0, share=False)
axs.format(xlabel='xlabel', ylabel='ylabel', suptitle='Panel axes demo')
for i, ax in enumerate(axs):
ax.format(title=f'Dataset {i+1}')
axs.contourf(data, cmap='glacial', levels=plot.arange(-1, 11),
colorbar='b', colorbar_kw={'label': 'colorbar'}, extend='both')
maxs.plot(data.mean(axis=1), np.arange(20), color='gray7')
maxs.format(title='Mean')
saxs.plot(data.std(axis=1), np.arange(20), color='gray7', ls='--')
saxs.format(title='Stdev')
Inset axes¶
Inset axes in ProPlot can be generated with the inset
or inset_axes
command. The generated axes are instances of XYAxes
, and therefore can be modified with the format
command. Passing zoom=True
to inset
draws a “zoom indication” with indicate_inset_zoom
, and the “zoom indication” lines are updated when the axis limits of the parent axes change. To modify the “zoom indication” line properties, simply use the zoom_kw
argument.
[3]:
import proplot as plot
import numpy as np
N = 20
state = np.random.RandomState(51423)
f, ax = plot.subplots()
x, y = np.arange(10), np.arange(10)
data = state.rand(10, 10)
m = ax.pcolormesh(data, cmap='Grays', levels=N)
ax.colorbar(m, loc='b', label='label')
ax.format(xlabel='xlabel', ylabel='ylabel')
axi = ax.inset([5, 5, 4, 4], transform='data', zoom=True,
zoom_kw={'color': 'red', 'lw': 2})
axi.format(xlim=(2, 4), ylim=(2, 4), color='red',
linewidth=1.5, ticklabelweight='bold')
axi.pcolormesh(data, cmap='Grays', levels=N)
ax.format(suptitle='Inset axes demo')