GIS plot 可视化 自定义matlibplot颜色条

# 可视化厚度
fig, ax = plt.subplots(figsize=(12, 6))
ax.set_facecolor('#FFFFFF')  # 设置背景颜色为黑色

# 绘制形状文件
#gdf.plot(ax=ax, color='red', edgecolor='red')
gdf_thickness.plot(ax=ax, column='thickness', markersize=5, alpha=0.7, legend=True,cmap=cmap_t,norm=norm_t,legend_kwds={
        'orientation': 'vertical',    # 垂直图例
        'label': 'Thickness (m)',     # 图例标题
        'shrink': 0.8,                # 图例尺寸比例
        'spacing': 'proportional',    # 保持颜色块比例一致
        'ticks': bounds_t,              # 显示所有边界值
        'ticklocation': 'auto'        # 自动定位刻度
    })

# 设置经纬度刻度标签,添加“N”和“E”以及“°”
ax.set_xticklabels([f'{int(x)}°E' for x in ax.get_xticks()])
ax.set_yticklabels([f'{int(y)}°N' for y in ax.get_yticks()])

plt.title('****')
# plt.xlabel('Longitude')
# plt.ylabel('Latitude')
plt.grid(False)
# 保存图片为 TIFF 格式
#plt.savefig(f'/root/results/厚度.tif', format='tiff', dpi=300)
plt.savefig(f'/root/results/厚度.png', format='png', dpi=300)
plt.show()

 

posted @ 2025-05-28 16:17  cup_leo  阅读(12)  评论(0)    收藏  举报