swcarpentry / python-novice-gapminder

Plotting and Programming in Python
http://swcarpentry.github.io/python-novice-gapminder/
Other
163 stars 427 forks source link

adding multiple plots during Plotting lesson in Python #566

Open bdemirb opened 3 years ago

bdemirb commented 3 years ago

When the gapminder_gdp_X data is plotted to see how GDP increased per year, it would be useful to generate multiple plots to compare gdps of different countries, especially where GDPs are too different in values. I believe adding this section to the lesson will help learners appreciate more the power of plotting in Python.

To this end, "subplots" command can be used to generate multiple plots:

fig, axs = plt.subplots(2,2, figsize=(8,8), sharex = True, sharey = False) fig.subplots_adjust(hspace=0.1, wspace = 0.1)

Let's assume we generate 4 plots in a 2x2 format --> (2,2) We adjust the size of the entire block --> (figsize=(8,8) Because the GDPs will be very different for countries (y-axis), choosing sharey = False is fair. Since the period covered by the data is the same, it is fair to keep the x-axis the same (sharex= True).

With hspace and wspace, the white space between plots can be adjusted.

hspace --> the height of the padding between subplots wspace --> the width of the padding between subplots,

lherwehe commented 2 years ago

@bdemirb I like this suggestion for the Plotting episode. I agree that it allows learners to further understand the real world application of this skill.

If it's added to the lesson, the content on creating figures with multiple plots with matplotlib from earthdatascience.org could be used (under CC 4.0 license like the Carpentries so can be used/built upon with attribution!).

I do understand that there's more of a need to trim than add to Carpentries lessons---directing to the earthdatascience.org lesson at the bottom under a header like Additional Resources could be a way to avoid making the lesson longer.

vahtras commented 2 years ago

Good idea, this is useful knowledge Olav

Den tis 7 sep. 2021 22:27bdemirb @.***> skrev:

When the gapminder_gdp_X data is plotted to see how GDP increased per year, it would be useful to generate multiple plots to compare gdps of different countries, especially where GDPs are too different in values. I believe adding this section to the lesson will help learners appreciate more the power of plotting in Python.

To this end, "subplots" command can be used to generate multiple plots:

fig, axs = plt.subplots(2,2, figsize=(8,8), sharex = True, sharey = False) fig.subplots_adjust(hspace=0.1, wspace = 0.1)

Let's assume we generate 4 plots in a 2x2 format --> (2,2) We adjust the size of the entire block --> (figsize=(8,8) Because the GDPs will be very different for countries (y-axis), choosing sharey = False is fair. Since the period covered by the data is the same, it is fair to keep the x-axis the same (sharex= True).

With hspace and wspace, the white space between plots can be adjusted.

hspace --> the height of the padding between subplots wspace --> the width of the padding between subplots,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/swcarpentry/python-novice-gapminder/issues/566, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLLJBO6GXXOIC5XJNRN2ZLUAZYSHANCNFSM5DTEFOQQ .