Hi, I'm new here and also quite a python/matplotlib-noob (as you will be able to recognize in my code-example<img class='smiley' src='http://n5.nabble.com/images/smiley/smiley_wink.gif' />).<br>
I have a problem with <b>plt.subplots</b>: When I plot any amount of bars (or different graphs/diags) in a for-loop through the subplots, and I try to format the yaxis-ticklabels (using the ticker module), the ticklabels are adapting all the subplots <b>except the last subplot yaxis</b><img class='smiley' src='http://n5.nabble.com/images/smiley/anim_crazy.gif' /><p>
Anyone any ideas or hints?<br>
Thanks a lot for any support!<br>
Best regards<p>
Here is the code:<br>
<div style="background-color:#e8e8e8; width: 50em; padding: 10px; border: 1px solid black"><font face="courier">import matplotlib.pyplot as plt<br>
import matplotlib.ticker as ticker<br>
import numpy as np<br>
from sympy import *<br>
from random import randint<br>
<br>
init_printing(use_unicode=True)<br>
np.seterr(all='ignore')<br>
<br>
<br>
def graph(numsubplots):<br>
fig1, axarr = plt.subplots(numsubplots, ncols=1, num="Subplot Problem", figsize=(10, 15), dpi=100)<br>
fontsize = 16<br>
<br>
for i in range(0, len(axarr)):<br>
ax = axarr[i]<br>
n = 5<br>
indx = np.arange(1, n+1)<br>
width = randint(1, 5)/10<br>
ax.barh(indx - width/2, [4, 7, 2, 1, 9], width, color='y', label="Me")<br>
ax.barh(indx + width/2, [3, 3, 0, 3, 3], width, color='r', label="The other")<br>
ax.set_xlabel('Hours', fontsize=fontsize)<br>
ax.set_ylabel('Day', fontsize=fontsize)<br>
ticklabelformat(ax, which='y', step=1, formating='day %d')<br>
<br>
ax.set_title('Hours working a day', fontsize=fontsize)<br>
ax.legend(fontsize=fontsize)<br>
ax.grid(True)<br>
<br>
for i in fig1.axes:<br>
plt.setp(i.get_xticklabels(), visible=True, rotation=30)<br>
plt.yscale('linear')<br>
plt.tight_layout()<br>
fig1.subplots_adjust(hspace=0.3)<br>
plt.show()<br>
<br>
<br>
def ticklabelformat(axe, which='xy', step=1, formating='%d'):<br>
majorlocator = ticker.MultipleLocator(step)<br>
majorformatter = ticker.FormatStrFormatter(formating)<br>
if which == 'y':<br>
axe.yaxis.set_major_locator(majorlocator)<br>
axe.yaxis.set_major_formatter(majorformatter)<br>
elif which == 'x':<br>
axe.xaxis.set_major_locator(majorlocator)<br>
axe.xaxis.set_major_formatter(majorformatter)<br>
else:<br>
axe.yaxis.set_major_locator(majorlocator)<br>
axe.yaxis.set_major_formatter(majorformatter)<br>
axe.xaxis.set_major_locator(majorlocator)<br>
axe.xaxis.set_major_formatter(majorformatter)<br>
<br>
<br>
if __name__ == "__main__":<br>
graph(3)</div><br>
<br/><hr align="left" width="300" />
View this message in context: <a href="http://matplotlib.1069221.n5.nabble.com/Subplots-problem-Last-tick-formatting-not-working-tp47986.html">Subplots problem: Last tick-formatting not working</a><br/>
Sent from the <a href="http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html">matplotlib - users mailing list archive</a> at Nabble.com.<br/>