Colorbars¶
Python¶
Keep the image artist returned by erlab.plotting.plot_array(). Pass that artist
to erlab.plotting.nice_colorbar() so the colorbar uses the same normalization:
import matplotlib.pyplot as plt
import erlab.plotting as eplt
fig, ax = plt.subplots(figsize=(3.4, 2.1), layout="compressed")
image = eplt.plot_array(data, ax=ax, cmap="Greys", gamma=0.5)
colorbar = eplt.nice_colorbar(
ax=ax,
mappable=image,
width=10,
minmax=True,
)
Use minmax=True when the colorbar only needs the displayed range endpoints. Supply
explicit ticks when readers must compare intermediate intensity values. Confirm that
the colorbar limits match the plotted image before export.
See erlab.plotting.nice_colorbar() for colorbar orientation, ticks, and placement.
Figure Composer¶
Layout: In Layout, use one axes.
Sources: In Sources, choose Add… and add the two-dimensional
dataarray.Recipe: Add an Image Plot step that targets the axes. Set Image data to
data.Add an ERLab Method step after the image. Select
nice_colorbar, target the same axes, and set Min/max ticks to True.