颜色图的自定义刻度线

Custom tick marks for colormap

如何确定要在颜色图上显示哪些数字?

例如GeoPandas 自动显示 0.2*10^90.4*10^90.6*10^9 ... 等等。如果我只想在正确的位置显示0500,000,0001,000,000,000怎么办?

import geopandas as gpd

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot(column='pop_est', legend=True)

您可以使用参数 legend_kwds 并将所需的报价作为列表传递。

import matplotlib.pyplot as plt
import geopandas as gpd

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot(
    column='pop_est', 
    legend=True,
    legend_kwds={'ticks': [0,500000000,1000000000]}
)
plt.show()