如何将下面的dataframe-info绘制到geopandas地图上?气泡大小应该取决于案例编号!
import geopandas
import geoplot
import pandas
d = {"Germany": 5, "United Kingdom" : 3, "Finland" : 1, "United States of America" : 4}
df = pandas.DataFrame.from_dict(d,orient='index')
df.columns = ["Cases"]
def WorldCaseMap():
world = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
ex = geoplot.polyplot(world)
WorldCaseMap()发布于 2020-03-23 18:17:18
创建包含质心几何体的第二个df,并将其绘制在第一个df上。下面是一个工作示例。
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
centroids = world.copy()
centroids.geometry = world.centroid
centroids['size'] = centroids['pop_est'] / 1000000 # to get reasonable plotable number
ax = world.plot(facecolor='w', edgecolor='k')
centroids.plot(markersize='size', ax=ax)

发布于 2020-03-23 18:04:52
我不确定geopandas会不会那么容易地给你一个气泡图。他们最好的例子是大合唱:
gpd_per_person = world['gdp_md_est'] / world['pop_est']
scheme = mapclassify.Quantiles(gpd_per_person, k=5)
# Note: this code sample requires geoplot>=0.4.0.
geoplot.choropleth(
world, hue=gpd_per_person, scheme=scheme,
cmap='Greens', figsize=(8, 4)
)我在这里找到了另一个使用geopandas的气泡图示例:https://residentmario.github.io/geoplot/gallery/plot_usa_city_elevations.html,但是我更喜欢这个情节示例的外观。(见下文)。
否则,请看plotly的示例,它们有一个气泡图:https://plot.ly/python/bubble-maps/
https://stackoverflow.com/questions/60811036
复制相似问题