MPLSAPLEL:添加打印图例并选择初始缩放

2024-10-01 00:28:34 发布

您现在位置:Python中文网/ 问答频道 /正文

有谁能指导我如何在mplsaplevel html绘图中添加图例吗。第二,如何选择初始变焦?在

在geopandas中打开shapefile并在交互式web地图上打印属性

示例代码:

import geopandas as gp
shapefile = 'shapefile/ne_50m_admin_0_countries.shp'
df_shapefile_countries = gpd.GeoDataFrame.from_file(shapefile)

import mplleaflet
ax = df_shapefile_countries .plot(column='pop_est')
mplleaflet.show(fig=ax.figure)

示例图像: 我想立即放大例如东南亚

World map


Tags: importweb绘图示例dfhtml地图ax
1条回答
网友
1楼 · 发布于 2024-10-01 00:28:34

我想,现在,你想要的功能还没有实现。在

关于图例的第一个问题,请看这里:https://github.com/jwass/mplleaflet/issues/35

对于第二个问题,创造性,你可以用你想要的坐标来创建一个透明的绘图。例如,请查看以下代码:

import matplotlib.pyplot as plt
import mplleaflet

fig, ax = plt.subplots()

# Your plot
ax.plot([10, 20, 30], [10, 20, 30])

# A second plot with some coordinates you want to use as the limits
# For instance, I want a plot with  x between (-100, 100)
ax.plot([-100, 100], [10, 30], alpha = 0)

mplleaflet.show(fig = ax.figure)

这远不是完美的,只有在你想看得更远的时候才有用(我不知道在英语里是不是这样说的),但总比没有好。 ax.set_xlim和/或ax.set_ylim不能工作,因此不能使缩放比您想在地图上绘制的更近。在

我希望有帮助。在

相关问题 更多 >