Skip to main content

Command Palette

Search for a command to run...

Day 2 of 100 Days of Code

Creating bar and bubble charts with Plotly

Published
1 min read
Day 2 of 100 Days of Code

Today I learned how to create bar charts and bubble charts with plotly and pandas in Python. I tried to recreate the "Life expectancy vs GDP per capita" graph by downloading the csv file that's available on the website and reading it into my dataframe in Pycharm, the IDE of my choice. I focused on data from just 1 year, to take out the time dimension of the data, and had to fiddle around with reducing the size of the bubbles, which represents the size of the population. Initially, I couldn't see any bubbles, presumably because the scale of the variable population was too large. I had to divide it by 10,000,000 (size=df['Pop']/10000000) to make all bubbles visible on the chart. I also tried to colour code the bubbles so countries belonging to the same continent would have the same colour. However, I didn't manage to figure this one out, so all of my bubbles remain purple for now...

image.png

E

Good luck with the challenge Sania Kudaibergen and happy new year :)

S

Thank you, Eleftheria! Excited to be part of the Hashnode community and Happy New Year to you too :)