proplot
proplot copied to clipboard
Colorbars within figures
Description
Unable to produce colorbars within different subplots. Matplotlib is able to produce a better colorbar.
Steps to reproduce in Matplotlib
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
fig, axs = plt.subplots(3, 3, constrained_layout=True)
for ax in axs.flat:
pcm = ax.pcolormesh(np.random.random((20, 20)))
fig.colorbar(pcm, ax=axs[0, :2], shrink=0.6, location='bottom')
fig.colorbar(pcm, ax=[axs[0, 2]], location='bottom')
fig.colorbar(pcm, ax=axs[1:, :], location='right', shrink=0.6)
fig.colorbar(pcm, ax=[axs[2, 1]], location='left')
plt.show()
Steps to reproduce in Proplot
import proplot as plt
fig, axs = plt.subplots(ncols=3, nrows=3)
for ax in axs:
pcm = ax.pcolormesh(np.random.random((20, 20)))
fig.colorbar(pcm, ax=axs[0, :2], shrink=0.6, location='bottom')
fig.colorbar(pcm, ax=[axs[0, 2]], location='bottom')
fig.colorbar(pcm, ax=axs[1:, :], location='right', shrink=0.6)
fig.colorbar(pcm, ax=[axs[2, 1]], location='left')
Matplotlib behavior: [What you expected to happen]
Proplot behavior: [What actually happened]
Proplot version
3.4.3 Matplotlib 0.9.5 Proplot
I encountered the same issue. I feel the Matplotlib way to locate colorbar is easier to manage (or readable) than the cols
and rows
setup in Proplot.
This error occurs because proplot's fig.colorbar
does not support multiple axes arguments.
@meng630 I agree. I would like to eventually support colorbars or legends along contiguous axes with both 1) matplotlib's fig.colorbar(ax=axs[:2])
syntax and 2) a proplot-only axs[:2].colorbar()
syntax (using a SubplotGrid.colorbar
method). I've run into cases where I need spanning labels across inner subplots in my own work, and had to use work-arounds in those cases. Hope to tackle this sometime this summer.
Turns out I already started a thread on this topic (#329), so further comments/discussion can go there.