Matlab axis control problem - solved

Dick Crepeau rhc2 at twcny.rr.com
Wed Oct 17 08:19:33 CEST 2007


I don't understand my earlier problem but the following code works no 
matter what the ylim is set to:

I reworked the example major_minor_demo1.py to find the answer.

thanks
Dick C

ps: I still can't post a reply since I read the list with my mozilla or 
konqueror browser and email separately with thunderbird - the reply 
address is not obvious.

from pylab import *
from matplotlib.ticker import MaxNLocator, MultipleLocator, 
FormatStrFormatter

x=[10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0]
y=x
figure(1)
ax=subplot(111)
ax.plot(array(x), array(y), 'x')

ymajorLocator   = MultipleLocator(5)
ymajorFormatter = FormatStrFormatter('%d')

ax.set_yscale('log')

ax.set_ylim(18.0, 58.0)

ax.yaxis.set_major_locator(ymajorLocator)
ax.yaxis.set_major_formatter(ymajorFormatter)

ax.yaxis.grid(True, linestyle='-', which='major')
show()




More information about the Python-list mailing list