PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, April 23, 2022

[FIXED] How can I adjust width and height in Pandas graph?

 April 23, 2022     pandas, pie-chart, plot, python     No comments   

Issue

I have a problem about showing image in terms of width and height. Some parts of it cannot be shown in png file.(Especially right side , some text cannot be shown) How can I fix it?.

enter image description here

Here is my code shown below.

plt.figure(figsize=(10,9))
ax = subplot_kw=dict(aspect="equal")
my_circle = plt.Circle((0, 0), 0.7, color='white')


d = plt.pie(symptoms['percentage'],
            autopct='%1.1f%%',
            pctdistance=0.85, 
            labeldistance=1.1,
            textprops = {'fontsize':10.5})

plt.axis('equal')
plt.gca().add_artist(my_circle)

plt.text(0, 
         0, 
         "Symptoms of Coronavirus",
         horizontalalignment='center',
         verticalalignment='center',
         size=16,
        )

plt.legend(symptoms['symptom'],loc='right',bbox_to_anchor=[1.2, 0.5])
plt.savefig('images/image2.png')
plt.savefig('images/image2.pdf')  
plt.show()

Solution

I solved the issue by writing this code shown below.

.....
plt.tight_layout()
plt.show()


Answered By - Tony Brand
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing