gpt4 book ai didi

python - rio.plot.show 带颜色条?

转载 作者:行者123 更新时间:2023-12-04 11:22:32 25 4
gpt4 key购买 nike

使用 rio.plot.show 后如何添加颜色条?
我尝试了很多东西,但遇到了各种错误

这是我尝试过的一种方法:

fig, ax = plt.subplots(figsize = (16, 16))

retted = rio.plot.show(ds, ax=ax, cmap='Greys_r')

fig.colorbar(retted, ax=ax)
plt.title("Original")
plt.show()

这有错误: AttributeError: 'AxesSubplot' object has no attribute 'get_array'

最佳答案

我做了什么david上面建议,它奏效了!

fig, ax = plt.subplots(figsize=(5, 5))

# use imshow so that we have something to map the colorbar to
image_hidden = ax.imshow(image_data,
cmap='Greys',
vmin=-30,
vmax=30)

# plot on the same axis with rio.plot.show
image = rio.plot.show(image_data,
transform=src.transform,
ax=ax,
cmap='Greys',
vmin=-30,
vmax=30)

# add colorbar using the now hidden image
fig.colorbar(image_hidden, ax=ax)

关于python - rio.plot.show 带颜色条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61327088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com