[英]unable to see bubbles in bubble map of plotly/python
我正在研究来自 kaggle 的 Ramen Ratings 数据集
我想使用scatter_geo
的plotly
查看评论数/国家/地区的plotly
我的代码:
country_count = df['Country'].value_counts()
import plotly.express as px
fig = px.scatter_geo(country_count, locations = country_count.index, size = country_count)
fig.show()
给了我这个:
请帮忙
由于scatter_geo
函数的locatioinmode
参数的默认设置,完整的分散是不可见的。 地点为country name
时,可改为国名。 修改后的代码如下:
import pandas as pd
import numpy as np
import plotly.express as px
import pycountry
df = pd.read_csv('ramen-ratings.csv')
country_count = df['Country'].value_counts()
country_count = country_count.reset_index().rename(columns={'index':'Country', 'Country':'Count'})
fig = px.scatter_geo(country_count, locations='Country', locationmode='country names', size='Count')
fig.show()
完整的文档可以在这里访问: https : //plotly.com/python-api-reference/generated/plotly.express.scatter_geo.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.