如plotly docs中所述,可以通过将键设置为列、将值设置为布尔值来传递dict,以便管理显示的内容和未显示的内容或格式:
hover_data = {"killed":True,"group":True,"lat":False,"long":False,"year":False}
fig = px.scatter_mapbox(df_clean, lat="lat", lon="long", hover_name="hover_title",
animation_frame="year",
color_discrete_sequence=["red"],
opacity = 1,
zoom=1, size="killed",
hover_data=hover_data)
这就产生了
RuntimeError: dictionary changed size during iteration
我错过了什么? 我看到有人在绘声绘色的上下文中使用dict({…}),但我看不出它是如何工作的,也看不到它的帮助
Traceback:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-75-881c99be1dc5> in <module>
7 opacity = 1,
8 zoom=1, size="killed",
----> 9 hover_data=hover_data)
10 # fig.update_layout(mapbox_style="open-street-map")
11
/opt/anaconda/envs/Python3/lib/python3.6/site-packages/plotly/express/_chart_types.py in scatter_mapbox(data_frame, lat, lon, color, text, hover_name, hover_data, custom_data, size, animation_frame, animation_group, category_orders, labels, color_discrete_sequence, color_discrete_map, color_continuous_scale, range_color, color_continuous_midpoint, opacity, size_max, zoom, center, mapbox_style, title, template, width, height)
1008 symbol mark on a Mapbox map.
1009 """
-> 1010 return make_figure(args=locals(), constructor=go.Scattermapbox)
1011
1012
/opt/anaconda/envs/Python3/lib/python3.6/site-packages/plotly/express/_core.py in make_figure(args, constructor, trace_patch, layout_patch)
1366
1367 args, trace_specs, grouped_mappings, sizeref, show_colorbar = infer_config(
-> 1368 args, constructor, trace_patch
1369 )
1370 grouper = [x.grouper or one_group for x in grouped_mappings] or [one_group]
/opt/anaconda/envs/Python3/lib/python3.6/site-packages/plotly/express/_core.py in infer_config(args, constructor, trace_patch)
1209 all_attrables += [group_attr]
1210
-> 1211 args = build_dataframe(args, all_attrables, array_attrables)
1212 if constructor in [go.Treemap, go.Sunburst] and args["path"] is not None:
1213 args = process_dataframe_hierarchy(args)
/opt/anaconda/envs/Python3/lib/python3.6/site-packages/plotly/express/_core.py in build_dataframe(args, attrables, array_attrables)
940 # argument_list and field_list ready, iterate over them
941 # Core of the loop starts here
--> 942 for i, (argument, field) in enumerate(zip(argument_list, field_list)):
943 length = len(df_output)
944 if argument is None:
RuntimeError: dictionary changed size during iteration
目前没有回答
相关问题 更多 >
编程相关推荐