unable to see bubbles in bubble map of plotly/python

Viewed 293

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: plotly image

Please help

1 Answers

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: enter image description here

The complete documentation can be accessed here: https://plotly.com/python-api-reference/generated/plotly.express.scatter_geo.html

Related