我正在尝试使用相同的颜色条制作一堆极坐标图。但是,设置绘图限制后颜色条会有所不同。在下面的代码片段中,我随机创建了 5 个地图,但绘制在固定范围内,但输出数字在颜色栏中仍然不同。
from numpy import linspace, pi, ndarray, random
import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import figure
lon = linspace(start=0, stop=2*pi, num=100)
colat = linspace(start=0, stop=9, num=10)
emission = ndarray(shape=(10, 100, 5), dtype=float)
for t in range(5):
emission[:, :, t] = random.rand(10, 100)
fig = figure(num='emission', figsize=(15, 15))
em_pos = [0.05, 0.1, 0.8, 0.8]
emc_pos = [0.9, 0.1, 0.05, 0.8]
for t in range(5):
fig.clear()
ax = fig.add_subplot(121, polar=True, position=em_pos)
axcont = ax.contourf(lon, colat, emission[:, :, t], vmin=0, vmax=2)
axc = fig.add_subplot(122, position=emc_pos)
fig.colorbar(mappable=axcont, cax=axc)
fig.savefig(fname='emission{0:d}.png'.format(t), format='png')