简体   繁体   中英

unable to see bubbles in bubble map of plotly/python

I am working on Ramen Ratings dataset from kaggle

I want to see the spread of no of reviews/country using scatter_geo from 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. It can be changed to country name when the locations are country names. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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