繁体   English   中英

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

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

我正在研究来自 kaggle 的 Ramen Ratings 数据集

我想使用scatter_geoplotly查看评论数/国家/地区的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.

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