【发布时间】:2020-07-07 09:15:47
【问题描述】:
当我尝试使用 contourf 绘制颜色条时,我得到了错误的配色方案和范围。它适用于 pcolormesh。我的目标是只为所有子图使用 1 个颜色条
fig = plt.figure(figsize=(9,8))
gs = gridspec.GridSpec(nrows=1, ncols=3)
color = plt.get_cmap('PRGn')
ax0 = plt.subplot(gs[0, 0])
ax0.contourf(x, y, z1, cmap=color)
ax1 = plt.subplot(gs[0, 1])
ax1.contourf(x, y, z2, cmap=color)
ax2 = plt.subplot(gs[0, 2])
ax2.contourf(x, y, z3, cmap=color)
# colorbar
im = plt.gca().get_children()[0]
cax = fig.add_axes([.918, 0.175, 0.025, 0.4])
cb = fig.colorbar(im, cax=cax)
谢谢
【问题讨论】:
标签: python python-3.x matplotlib subplot colorbar