Problem with a Data Science Comulative Project

Getting a empyty png file which is only white
graphs are plotted.
It’s a jupyter Notebook Proect and I’am using it
Thats the code for this part :


Left plot Netflix

ax1 = plt.subplot(1, 2, 1)
ax1.set_ylabel(“Stock Price”)

Right plot Dow Jones

ax2 = plt.subplot(1, 2, 2)
plt.plot(dowjones_stocks[‘Date’],dowjones_stocks[‘Adj Close’])
ax2.set_title(“Dow Jones”)
ax2.set_ylabel(“Stock Price”)

Hi @frederic_1102 - welcome to the forum.

Can you try swapping the last two lines you’ve posted, like so:


Let me know if that fixes it.


1 Like

ok it works don’t know show must be behind but it works it’s strange because the save is normally in another step in the capstone project and before is written remember to plot

1 Like

Good to know I solved your problem.

The reason why you need to use after plt.savefig() is explained in the documentation. Specifically, the “note” under “use show()”:


Because closing a figure window invokes the destruction of its plotting elements, you should call savefig() before calling show if you wish to save the figure as well as view it.

Your original code had these calls the other way around, so the blank figure was correct behaviour from matplotlib; as it was erasing the plots after exited, plt.savefig("filename1.png") had nothing to work with. :slight_smile:

1 Like

I was confused becuase the order to do in the jupyter notebook project is false written. Thx u a lot.

1 Like