mplleaflet:添加图例并选择初始缩放

时间:2016-05-07 17:38:39

标签: python matplotlib leaflet geopandas

任何人都可以指导我如何在mplleaflet html图中添加图例。第二,如何选择初始变焦?

在geopandas中打开shapefile并在交互式Web地图上绘制属性

示例代码:

.oval {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  display: inline-block;
  box-sizing: content-box;
  width: 200px;
  height: 50px;
  padding: 5px;
  border: none;
  -webkit-border-radius: 47% / 50%;
  border-radius: 47% / 50%;
  font: normal 100%/normal "Courier New", Courier, monospace;
  color: white;
  text-align: center;
  vertical-align: middle;
  -o-text-overflow: clip;
  text-overflow: clip;
  background: #99cc00;

}


.oval span {
  vertical-align: middle;
}

示例图片: 我想立即缩放到东南亚

World map

1 个答案:

答案 0 :(得分:2)

我认为,现在,您想要的功能尚未实现。

有关图例的第一个问题,请查看此处: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无法正常工作,因此您无法比地图中的绘图更接近缩放。

我希望它有所帮助。

相关问题