0

I am trying to display a chart using matplotlib. But my labels are so big that they are overlapping each other. I want to show it cleanly no overlapping. How can I do that? I am now using below code:

import matplotlib.pyplot as plt

x = ['jdwdw723@gmail.com' ,'emcast.test10@gmail.com', 'pbChinaTester@clp.com']
y = [10,25,6]

plt.plot(x,y)

plt.xlabel("loginId")
plt.ylabel("times appeared in the data")

plt.title("loginId Graph")
plt.tight_layout()
plt.show()
Zubayer
  • 571
  • 1
  • 8
  • 16
  • 2
    You could rotate the labels by 90 degrees? `plt.tick_params(axis='x', labelrotation=90)`? – JohanC Feb 04 '21 at 08:48

1 Answers1

1

I tried your example code, and it doesn't seem to be overlapping there. There are many possibilities. One, commonly used, is to rotate the labels.

You can do it like this:

plt.xticks(rotation=45)

There are more ideas in Changing the “tick frequency” on x or y axis in matplotlib? and in reducing number of plot ticks.

I created an example notebook here, feel free to duplicate and play with it.

Jakub Žitný
  • 962
  • 1
  • 9
  • 38