0

I'm creating a plot using the following code:

[...]
# print a bar plot of the results
plt.bar(range(length), buckets)
# add x-axis ticks (dates)
plt.xticks(range(length), days, rotation=70)
# some cosmetics: hide all ticks
plt.setp(plt.gca().get_xticklabels(), visible=False)
# show every 30th tick again
plt.setp(plt.gca().get_xticklabels()[::30], visible=True)
# show the result
plt.show()

My problem is that the names of my X Axis are way to big (in terms of length). Is there a way to show only the first 5 (or n) chars of every tick? Or possibly edit them completely?

DavidG
  • 24,279
  • 14
  • 89
  • 82
Aventinus
  • 1,322
  • 2
  • 15
  • 33
  • It may well be that the solution to the duplicate does not directly help you. In this case you would need to make it clear in how far you need specific help here. – ImportanceOfBeingErnest Jul 11 '17 at 10:25
  • It is a duplicate. I'm sorry, I wasn't aware of this answer. You can close the question. Sorry for spamming. – Aventinus Jul 11 '17 at 10:26
  • 1
    It's not automatically a bad thing to ask a duplicate question. Sometimes you just use different words and thus don't find what you're looking for. Asking then a question with these words in it, which will be marked as duplicate, may be beneficial for future readers who use the same wording and arrive at a solution through the duplicate link. – ImportanceOfBeingErnest Jul 11 '17 at 10:41

0 Answers0