python colorbar非线性映射_Python-如何使colorbar方向水平?

所以我有一个底图,顶部有一个colormesh,另一个设置为cbar的颜色条.我希望colorbar方向是水平而不是垂直,但是当我在extend =’max’之后的cbar = m.colorbar行中设置orientation =’horizo​​ntal’时,我得到以下错误:“colorbar()获得了多个值关键字参数’orientation’“

有人在另一个问题上解释了为什么会发生这种情况,但老实说,我无法理解答案或看到如何解决问题的解释.有人可以帮忙吗?我尝试使用plt.colorbar,但由于某些原因不接受我的刻度设置.

这是我之前的情节……

#Set cmap properties

bounds = np.array([0.1,0.2,0.5,1,2,3,4,6,9,13,20,30])

norm = colors.LogNorm(vmin=0.1,vmax=30) #creates logarithmic scale

#Create basemap

fig = plt.figure(figsize=(15.,10.))

m = Basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90,llcrnrlon=0,urcrnrlon=360.,lon_0=180.,resolution='c')

m.drawcoastlines(linewidth=1)

m.drawcountries(linewidth=1)

m.drawparallels(np.arange(-90,90,30.),linewidth=0.3)

m.drawmeridians(np.arange(-180.,180.,90.),linewidth=0.3)

meshlon,meshlat = np.meshgrid(lon,lat)

x,y = m(meshlon,meshlat)

#Plot variables

trend = m.pcolormesh(x,y,lintrends_36,cmap='jet', norm=norm, shading='gouraud')

#Set plot properties

plt.tight_layout()

#Colorbar

cbar=m.colorbar(trend, size='3%',ticks=bounds,extend="max") #THIS LINE

cbar.set_label(label='Linear Trend (mm/day/decade)',size=30)

cbar.set_ticklabels(bounds)

#Titles & labels

plt.suptitle('Linear Trends of Precipitation (CanESM2)',fontsize=40,y=0.962)

plt.title('a) 1979-2014',fontsize=40)

plt.ylabel('Latitude',fontsize=30)

plt.show()

尝试定位时(所有其他代码都相同)……

地图看起来像这样.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值