gpt4 book ai didi

python - 具有对数比例色图的 Geopandas

转载 作者:行者123 更新时间:2023-12-05 01:10:41 26 4
gpt4 key购买 nike

如果我有下面的图,如何将颜色图/图例转换为对数刻度?

import geopandas as gpd
import matplotlib.pyplot as plt

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world = world[(world.pop_est>0) & (world.name!="Antarctica")]
fig, ax = plt.subplots(1, 1)
world.plot(column='pop_est', ax=ax, legend=True)

enter image description here

最佳答案

GeoPandas 绘图使用的是 matplotlib,因此您可以使用它提供的色图标准化。请注意,我还将最小值和最大值指定为我正在绘制的列的最小值和最大值。

world.plot(column='pop_est', legend=True, norm=matplotlib.colors.LogNorm(vmin=world.pop_est.min(), vmax=world.pop_est.max()), )

map

关于python - 具有对数比例色图的 Geopandas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63904461/

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