bluesky
bluesky

Reputation: 153

Why isn't my matplotlib pie chart saving as a png image properly?

Here is an image of my code: enter image description here

When I open my file explorer and try to view this image only a plain white image is displayed:

enter image description here

You can see that my bar chart images have saved just fine, so I'm a bit confused as to why the pie charts aren't viewable.

Anyone know what the problem might be??

Upvotes: 1

Views: 1569

Answers (2)

You must write like this:

plt.savefig("Visualsations/plot2.png",dpi=300) 
         
plt.show()  

Save the figure first, and then use plt.show() to show it. The order matters; always check it.

Upvotes: 2

kiwi
kiwi

Reputation: 585

I'm not completely sure if this is the solution but perhaps try and remove the bit where it says plt.show(). I think this might be preventing the image from saving.

Upvotes: 4

Related Questions