Python散点图可视化

时间:2019-07-22 18:14:32

标签: python-3.x

如何在Google地图上绘制经度和​​纬度属性数据的散点图? python中的哪个头文件将支持地图绘制?

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用gmplot软件包?

from gmplot import gmplot

# Place map
gmap = gmplot.GoogleMapPlotter(37.766956, -122.438481, 13)

# Polygon
golden_gate_park_lats, golden_gate_park_lons = zip(*[
    (37.771269, -122.511015),
    (37.773495, -122.464830),
    (37.774797, -122.454538),
    (37.771988, -122.454018),
    (37.773646, -122.440979),
    (37.772742, -122.440797),
    (37.771096, -122.453889),
    (37.768669, -122.453518),
    (37.766227, -122.460213),
    (37.764028, -122.510347),
    (37.771269, -122.511015)
    ])
gmap.plot(golden_gate_park_lats, golden_gate_park_lons, 'cornflowerblue', edge_width=10)

# Scatter points
top_attraction_lats, top_attraction_lons = zip(*[
    (37.769901, -122.498331),
    (37.768645, -122.475328),
    (37.771478, -122.468677),
    (37.769867, -122.466102),
    (37.767187, -122.467496),
    (37.770104, -122.470436)
    ])
gmap.heatmap(top_attraction_lats, top_attraction_lons)

# Marker
hidden_gem_lat, hidden_gem_lon = 37.770776, -122.461689
gmap.marker(hidden_gem_lat, hidden_gem_lon, 'cornflowerblue')

# Draw
gmap.draw("my_map.html")

生成一张简单的旧金山地图,其中使用plot标记路线,并使用heatmap绘制景点热图:

Demo

这是处于开发人员模式的Google Maps,因为我没有为该API付费,但是我认为,如果您注册了账单,它们将使您可以完全访问未加水印的版本。有关详情,请参见此other question