recentpopularlog in

kme : matplotlib   16

python - Why is my xlabel cut off in my matplotlib plot? - Stack Overflow
<code class="language-python">import matplotlib.pyplot as plt

plt.gcf().subplots_adjust(bottom=0.15)</code>
to make room for the label.

Edit: Since i gave the answer, matplotlib has added the tight_layout() function. So i suggest to use it:
<code class="language-python">plt.tight_layout()</code>
should make room for the xlabel.
python  matplotlib  annoyance  ticklabels  solution 
25 days ago by kme
Rotating custom tick labels — Matplotlib 3.1.3 documentation
This might be enough:
<code class="language-python">
plt.subplots_adjust(bottom=0.25)
</code>

<code class="language-python">import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [1, 4, 9, 6]
labels = ['Frogs', 'Hogs', 'Bogs', 'Slogs']

plt.plot(x, y)
# You can specify a rotation for the tick labels in degrees or with keywords.
plt.xticks(x, labels, rotation='vertical')
# Pad margins so that markers don't get clipped by the axes
plt.margins(0.2)
# Tweak spacing to prevent clipping of tick-labels
plt.subplots_adjust(bottom=0.15)
plt.show()</code>
python  plotting  matplotlib  ticks  ticklabels  annoyance  solution 
25 days ago by kme
How to Rotate X-axis Tick Label Text in Matplotlib | Delft Stack
<code class="language-bash">plt.setp(ax.get_xticklabels(), rotation=45, ha='right')</code>
python  matplotlib  axes  ticklabels  annoyance  solution 
25 days ago by kme

Copy this bookmark:





to read