[英]How to show all the labels in matplotlib?
I am trying to display a chart using matplotlib.我正在尝试使用 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()
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? 在 matplotlib 中更改 x 或 y 轴上的“滴答频率”有更多想法? and in reducing number of plot ticks .
并减少 plot 滴答声的数量。
I created an example notebook here , feel free to duplicate and play with it.我在这里创建了一个示例笔记本,请随意复制和使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.