Sanjay M. P.
Sanjay M. P.

Reputation: 1009

How to prevent overlapping of text in Graphs using Matplotlib

Using Jupyter Notebook to visual csv data, there are names printed on the x axis along side amount, how do i reduced its fonts and make sure that the names don't overlap, atleast print 10 characters of the name.

plt.bar(monthly_owner.Owner.head(6),monthly_owner.Amount.head(6))
plt.xlabel('Owner', fontsize=15)
plt.ylabel('Amount', fontsize=15)
plt.title('AWS Monthly Cost by Owner')
plt.savefig('plot3.png', dpi=300, bbox_inches='tight')
plt.show()

overlapped graph

Upvotes: 1

Views: 188

Answers (1)

Subasri sridhar
Subasri sridhar

Reputation: 831

You can rotate your label to show the owner's name using the below code.

plt.xticks(rotation=90)

Upvotes: 1

Related Questions