简体   繁体   English

无法在 plotly/python 的气泡图中看到气泡

[英]unable to see bubbles in bubble map of plotly/python

I am working on Ramen Ratings dataset from kaggle我正在研究来自 kaggle 的 Ramen Ratings 数据集

I want to see the spread of no of reviews/country using scatter_geo from plotly我想使用scatter_geoplotly查看评论数/国家/地区的plotly

my code:我的代码:

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()

gave me this:给了我这个:情节形象

Please help请帮忙

The complete scatter is not visible because of the default setting for the locatioinmode parameter of the scatter_geo function.由于scatter_geo函数的locatioinmode参数的默认设置,完整的分散是不可见的。 It can be changed to country name when the locations are country names.地点为country name时,可改为国名。 The modified code is as follows:修改后的代码如下:

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()

The graph obtained is as follows:得到的图形如下: 在此处输入图片说明

The complete documentation can be accessed here: https://plotly.com/python-api-reference/generated/plotly.express.scatter_geo.html完整的文档可以在这里访问: https : //plotly.com/python-api-reference/generated/plotly.express.scatter_geo.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM