Closed annajiat closed 1 year ago
Thanks for discovering this! I just tried testing this and on my system it looks like it works if you just run a plt.savefig
right after a plot
command, e.g.,
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv('data/gapminder_all.csv', index_col='country')
data.plot(kind='scatter', x='gdpPercap_2007', y='lifeExp_2007', s=data['pop_2007']/1e6)
plt.savefig('all_data.png')
In "plotting" episode, at https://swcarpentry.github.io/python-novice-gapminder/09-plotting/index.html#:~:text=When%20using%20dataframes under "Saving your plot to a file", the workaround to use the variable and calling fig.savefig() no longer works and generates empty file. However, the original solution plt.savefig() works now. We can choose to keep the example for the idea of using a variable.
Proposed:
Existing: