How to show truncated X-axis in matplotlib (seaboard) heatmap
<p>I have the following image:</p>

<p><a href="http://i.stack.imgur.com/sUDks.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/sUDks.jpg" alt="enter image description here"></a></p>

<p>Created with this code:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

# create some random data
data = pd.DataFrame(np.random.rand(11, 5), columns=['A', 'B', 'C', 'D', 'E'], index = ['yyyyyyyy - ' + str(x) for x in range(2000, 2011, 1)])

# plot heatmap
ax = sns.heatmap(data.T)

# turn the axis label
for item in ax.get_yticklabels():
    item.set_rotation(0)

for item in ax.get_xticklabels():
    item.set_rotation(90)

# save figure

plt.savefig('seabornPandas.png', dpi=100)
plt.close()
</code></pre>

<p>My question is how can I adjust the image so that the truncated x-axis showed its full string? </p>

<p>There's a convenient way to do this through a <code>subplots_adjust</code> method: </p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

# create some random data
data = pd.DataFrame(np.random.rand(11, 5), columns=['A', 'B', 'C', 'D', 'E'], index = ['yyyyyyyy - ' + str(x) for x in range(2000, 2011, 1)])

# plot heatmap
plt.ion()
ax = sns.heatmap(data.T)
# adjust to taste
ax.figure.subplots_adjust(bottom = 0.25)

# turn the axis label
for item in ax.get_yticklabels():
    item.set_rotation(0)

for item in ax.get_xticklabels():
    item.set_rotation(90)

# save figure
plt.savefig('seabornPandas.png', dpi=100)
</code></pre>

<p><a href="http://i.stack.imgur.com/X8gIC.png" rel="nofollow"><img src="http://i.stack.imgur.com/X8gIC.png" alt="xaxis-space"></a></p>

python pandas matplotlib seaborn