簡體   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