Last answered:

28 Feb 2023

Posted on:

23 Feb 2023

1

Resolved: Saving the figures using python

Hi,

In python, I have checked the figures that i have created and found out that they do not have the graph that i have created.  


Here is my code.

plt.figure(figsize = (9,6))
plt.barh(y = df_use_cars["Brand"], 
         width = df_use_cars["Cars Listings"], 
         color = colors)
plt.yticks(fontsize = 13)
plt.xticks(fontsize = 13)
plt.title("Cars Listings by Brand", fontsize = 16, fontweight = "bold")
plt.xlabel("Number of Listings", fontsize = 13)
plt.tight_layout()
plt.show()
plt.savefig("Cars Listings by Brand HBar.png")


The code is correct and the outcome is correct but the saved png file is blank. 

I would appreciate your help.

Thanks

2 answers ( 2 marked as helpful)
Instructor
Posted on:

27 Feb 2023

0

Hi Ashraf, 

thanks for reaching out! Your code is indeed correct, however there is a small mistake in the video. If you swap the two last lines of your code your picture should export fine. So, have:

plt.savefig("Cars Listings by Brand HBar.png")
plt.show()

I hope this helps!


Best, 

365 Eli

Posted on:

28 Feb 2023

1

Hi Elitsa,


Perfect, thanks alot for your support!


Kind regards

Ashraf

Submit an answer