我是 Python 的新手。你能帮我对颜色条进行适当的定制吗?我已经尝试过来自网络的几种变体,但它们无法以正确的方式工作。我有以下带有颜色条的图表:
这是代码:
set_cmap('rainbow')
contourf(0.5*(data1+data2))
xlabel (r'across track $\rm\,[pixels]$')
ylabel (r'along track $\rm\,[pixels]$')
cbar = plt.colorbar()
cbar.set_label('radiance', rotation=270)
title('1.6 mue (avg: 5992-6012 cm^(-1))')
# Show the major grid lines
plt.grid(b=True, which='major', color='#666666', linestyle='-')
# Show the minor grid lines
plt.minorticks_on()
plt.grid(b=True, which='minor', color='#666666', linestyle='-', alpha=0.4)`fig=plt.figure()
我需要将颜色条截断为 0 到 9 之间的值,即 0、1、2、3、4、5、6、7、8、9,并为每个值创建一个新颜色。
像 cbar = plt.clim(0, 9) 这样的 PS 命令不起作用。
提前致谢!
函数式编程
相关分类