我试图为一个数据帧创建一个散点图,其中index=countries,columns=some variables(如下所示)
data= {'Ss': [14, 14, 30, 878], 'Cs': [20, 116, 321, 3883], 'Rs': [0, 0, 34, 1192]}
affs_df= pd.DataFrame(index= ['Argentina', 'Austria', 'Australia', 'United States'], data= data)
smfig = go.Figure()
col_names = affs_df.columns
for n in col_names:
smfig.add_trace(go.Scattergeo(
locationmode = 'country names',
marker = dict(
size= affs_df[n],
line_color= 'rgb(40, 40, 40)',
line_width= 0.5,
sizemode= 'area'),
name= n))
smfig.update_layout(
title_text= 'Affiliations of publications',
showlegend= True,
geo= dict(
scope= 'world',
landcolor= 'rgb(217, 217, 217)'))
但我有个错误:
ValueError:
Invalid value of type 'pandas.core.series.Series' received for the 'size' property of scattergeo.marker
我将大小特性更改为size= affs_df[n].to_list()
,但结果是一个空映射
目前没有回答
相关问题 更多 >
编程相关推荐