1
我想在一個地塊中繪製兩條彩色地圖,並帶有地圖。不幸的是,色彩條本身就和情節一樣大。即使在色差代碼中使用縮小,它也只會縮小色彩條,但不會佔用它們的大小。我如何縮小色板佔用的區域?
有沒有簡單的方法來爲我的情節使用更多的空間,並減少了彩色空間的空間?還有一種簡單的方法可以讓色板在底部同時出現嗎?
代碼如下
plt.clf()
my_cmap = cm.get_cmap('YlOrRd')
cs = map.contourf(x,y,bj,levels = Y,cmap=my_cmap,locator=mpl.ticker.LogLocator())
norm = mpl.colors.BoundaryNorm(bounds, my_cmap.N)
cb1 = plt.colorbar(cmap=my_cmap,
norm=norm,
boundaries=bounds,
extend='both',
orientation="horizontal",
ticks=bounds,
shrink = 0.35)
cb1.set_label('Increase in Black Carbon')
bj = -bj
ymap = cm.get_cmap('PuBu')
cs = map.contourf(x,y,bj,levels = Y,cmap=ymap,locator=mpl.ticker.LogLocator())
# set colourbar with location and size, with labels.
norm = mpl.colors.BoundaryNorm(bounds,ymap.N)
cb2 = plt.colorbar(cmap=my_cmap,
norm=norm,
boundaries=bounds,
extend='both',
orientation="horizontal",
ticks=bounds,
shrink=0.35)
cb2.set_label('Decrease in Black Carbon')
font = {'family' : 'serif',
'color' : 'black',
'weight' : 'bold',
'size' : 21,
}
#add plot details
plt.title(r'Black Carbon surface concentrations changes in %s 2006 compared with %s 2006 ($\mu$gm$\^3$)'%(g,d) ,fontdict=font)
map.drawcoastlines(linewidth=0.75)
map.drawcountries(linewidth=0.25)
#show plot
plt.show()
歡迎來到StackOverflow!請嘗試發佈您用於生成劇情的代碼的最小**工作**示例。你會經常得到更好的迴應! – Hooked