[英]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.