如何使用 pandas / geopandas 增加我的图的 bin 数量?

How can I increase the number of bins for my plot using pandas / geopandas?

目前我的很多数据在一个 bin 中显示了很大范围的值 - 所有数据都从 0 到 1.31,但我的顶部 bin 颜色保持在 0.15 到 1.31。

这是我的绘图代码:

merged.plot(column='vaccinations_per_person', scheme="quantiles", figsize=(25, 20),
           legend=True, norm=colour, cmap='Oranges', missing_kwds = 
           dict(color = "lightgrey", label = "No Data"))
plt.title('Vaccinations per Person',fontsize=25)

这是我的传说:

  • 使用带有散点图的颜色图,并且没有限制 bins
import pandas as pd
import io, requests, matplotlib

dfraw = pd.read_csv(io.StringIO(requests.get("https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/vaccinations/vaccinations.csv").text))

cmap = matplotlib.colors.LinearSegmentedColormap.from_list("", ["aqua","limegreen","green"])

dfraw["date"] = pd.to_datetime(dfraw["date"])
dfp = (dfraw.sort_values(["iso_code","date"])
 .groupby(["iso_code"], as_index=False).last()
 .loc[:,["iso_code","people_vaccinated_per_hundred"]]
 .dropna()
 .plot(kind="scatter", x="iso_code", y="people_vaccinated_per_hundred", c="people_vaccinated_per_hundred", cmap=cmap)
)

使用具有相同颜色图的 geopandasfolium 以及更多准备工作,您可以:

您可以通过将垃圾箱的数量指定为 k=10(如果您想要 10 个)来轻松完成此操作。

 merged.plot(column='vaccinations_per_person', scheme="quantiles", figsize=(25, 20),
           legend=True, norm=colour, cmap='Oranges', missing_kwds = 
           dict(color = "lightgrey", label = "No Data"), k=10)