【发布时间】:2020-12-17 05:43:23
【问题描述】:
我只使用 Python,想调整热图的最大不透明度。正如您在下图中看到的,基本地图是完全不可见的。 我想查看更多底图。如何调整HeatMap 中的参数,以便仅使用Python 增加热图图层的不透明度?
here 中的问题完全相同,但它使用 Leaflet.js,解决方案是使用 CSS,而不是 Python。不管怎样,这是我用来制作地图的代码。
import folium
from folium import plugins
from folium.plugins import HeatMap
import pandas as pd
df = pd.read_csv("the_data.csv") # the data contains lat and long columns, I can't share the data...
coords = [(lat, lng) for lat, lng in zip(restaurants[0].lat.to_list(), restaurants[0].lon.to_list())]
m = folium.Map([-6.204725,106.847009], tiles="CartoDB dark_matter", zoom_start=14)
HeatMap(coords,
min_opacity=0.4,
max_val = 0.5,
gradient={.2: '#482d61', .5:"#5aa7d6", 1: '#fffaad'}).add_to(folium.FeatureGroup(name='Heat Map').add_to(m))
folium.LayerControl().add_to(m)
m.save("heatmap.html")
【问题讨论】:
标签: python heatmap opacity folium