Bubbleplot usando seaborn —-#

  • 0:00 min | Última modificación: Octubre 13, 2021 | [YouTube]

[1]:
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
[2]:
gapminder = pd.read_csv(
    "https://raw.githubusercontent.com/jdvelasq/datalabs/master/datasets/gapminder.csv",
)

year_2017 = gapminder[gapminder.year == 2007]

year_2017.head()
[2]:
Unnamed: 0 country year population cont life_exp gdp_cap
0 11 Afghanistan 2007 31889923.0 Asia 43.828 974.580338
1 23 Albania 2007 3600523.0 Europe 76.423 5937.029526
2 35 Algeria 2007 33333216.0 Africa 72.301 6223.367465
3 47 Angola 2007 12420476.0 Africa 42.731 4797.231267
4 59 Argentina 2007 40301927.0 Americas 75.320 12779.379640
[3]:
sns.scatterplot(
    data=year_2017,
    x="gdp_cap",
    y="life_exp",
    size="population",
    legend=False,
    sizes=(20, 2000),
)

plt.show()
../../_images/02_seaborn_notebooks_2-23_relational_scatterplot_3_0.png