首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >matplotlib xticks标签重叠

matplotlib xticks标签重叠
EN

Stack Overflow用户
提问于 2012-09-05 10:24:49
回答 1查看 14.8K关注 0票数 14

使用以下代码,我无法在xtick之间获得更好的空格:

代码语言:javascript
复制
import random
import matplotlib.pyplot as plt

coverages = [random.randint(1,10)*2] * 100
contig_names = ['AAB0008r'] * len(coverages)
fig = plt.figure()
fig.clf()
ax = fig.add_subplot(111)

ax.yaxis.grid(True, linestyle='-', which='major', color='grey', alpha=0.5)

ind = range(len(coverages))
rects = ax.bar(ind, coverages, width=0.2, align='center', color='thistle')
ax.set_xticks(ind)
ax.set_xticklabels(contig_names)
#function to auto-rotate the x axis labels
fig.autofmt_xdate()

plt.show()

如何在xtick之间获得更多的空间,使它们看起来不再重叠?

提前谢谢你。

EN

回答 1

Stack Overflow用户

发布于 2012-09-05 15:51:12

您可以尝试更改图形大小、xticklabels的大小、其旋转角度等。

代码语言:javascript
复制
# Set the figure size
fig = plt.figure(1, [20, 8])

# Set the x-axis limit
ax.set_xlim(-1,100)
# Change of fontsize and angle of xticklabels
plt.setp(ax.get_xticklabels(), fontsize=10, rotation='vertical')
票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12273712

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档