- 积分
- 11225
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2020-12-28
- 最后登录
- 1970-1-1
|
发表于 2022-12-7 10:27:53
|
显示全部楼层
 - import cmaps
- from matplotlib.colors import ListedColormap
- import numpy as np
- import matplotlib.pyplot as plt
- import matplotlib as mpl
- rgb=(
- [ 43,67,255],
- [ 91,130,255],
- [ 136,178,255],
- [ 184,218,255],
-
- [ 255,255,255],
- [ 255,255,255],
-
- [ 255,190,190],
- [ 255,142,142],
- [ 255,97,97],
- [ 255,49,49],
- )
- rgb=np.array(rgb)/255.0
- newcmap=ListedColormap(rgb)
- clevs = np.linspace(0,100,11)
- fig=plt.figure(figsize=(10,8),dpi=150)
- norm =mpl.colors.Normalize(vmin=0, vmax=100)
- ax=fig.add_axes()
- fc1=fig.colorbar(
- mpl.cm.ScalarMappable(norm=norm,cmap=newcmap, ),
- cax=ax,
- ticks = clevs,
- orientation='horizontal',
- )
- ax2=fc1.ax
- ax2.xaxis.set_ticks_position('top')#将数值刻度移动到上边
- ax3=ax2.secondary_xaxis('bottom')#新建ax3,使ax3与ax2完全相同,但是是处于下部
- ax3.set_xticks([5,15,25,35,45,55,65,75,85,95])
- ax3.set_xticklabels([0,10,20,30,40,50,60,70,80,90],ha="center")
|
|