[英]Geopandas plot makes label for every datapoint instead of a colorbar
total_customers_affected_by_city必須是字符串,因此它被視為分類。 將其更改為數字列,您將獲得一個顏色條。 下面的代碼顯示了您在我故意將列設置為字符串而不是數字的地方所描述的內容。
import geopandas as gpd
import numpy as np
gdf_MA_outage = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres")).loc[
lambda d: (d["continent"] == "Europe") & (~d["iso_a3"].isin(["-99", "RUS"]))
]
gdf_MA_outage["total_customers_affected_by_city"] = np.random.randint(1, 200000, len(gdf_MA_outage)).astype(str)
gdf_MA_outage.plot(
column="total_customers_affected_by_city",
cmap="OrRd",
figsize=(16, 16),
legend=True,
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.