Python 将多个Vega/vincent图表添加到一个Folium弹出窗口
我想使用Vincent/Vega将两个图表添加到Folium地图弹出窗口中。我用图表创建了两个vincent对象,并试图通过链接两个Python 将多个Vega/vincent图表添加到一个Folium弹出窗口,python,folium,vega,Python,Folium,Vega,我想使用Vincent/Vega将两个图表添加到Folium地图弹出窗口中。我用图表创建了两个vincent对象,并试图通过链接两个add\u child()方法将它们添加到弹出窗口实例中。但只有第二个图表被渲染 这是我使用的代码,但没有数据,只是对图表所用数据的描述 from folium import Map, CircleMarker, Vega, Popup from vincent import Bar import math map = Map(zoom_start=8, tile
add\u child()
方法将它们添加到弹出窗口实例中。但只有第二个图表被渲染
这是我使用的代码,但没有数据,只是对图表所用数据的描述
from folium import Map, CircleMarker, Vega, Popup
from vincent import Bar
import math
map = Map(zoom_start=8, tiles='cartodbpositron',
location = [-73.5, 45.2]))
# zones is a pandas dataframe with lat/lng pairs of points.
for i, zone in zones.iterrows():
# weekday_pings: a pandas groupby aggregation of most frequent day of week in a dataframe
# hour_pings: a pandas groupby aggregation of most frequent hour of day in a dataframe
dayvega = Bar(weekday_pings, width=300,
height=150).axis_titles(x='Weekday', y='Pings')
daychart = Vega(dayvega.to_json(), width=vega.width+50, height=vega.height+50)
timevega = Bar(hour_pings, width=300,
height=150).axis_titles(x='Hour', y='Pings')
timechart = Vega(timevega.to_json(), width=vega.width+50, height=vega.height+50)
map.add_child( CircleMarker(
location = [zone['latitudeE7'], zone['longitudeE7']],
radius = int(math.sqrt(zone['cluster_size'])/10 + 2),
fill_opacity = 0.8, color=None,
fill_color = ('#274cc9'),
popup = Popup(max_width=chart.width[0]).add_child(daychart).add_child(timechart)
) )
结果如下:只渲染第二个子对象
最后,我没有找到解决方案,所以我切换到Altair来制作图表,使用在一个图中制作多个图表