Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Matplotlib axis control problem

Thread Tools

Matplotlib axis control problem

Dick Crepeau
Posts: n/a
I would like to control the y axis of a plot. The following code does
exactly what I want it to! On my linux computer it sets the y axis
limits to 18.0 minimum, 58.0 maximum, plots some points on y=x, provides
ticks at 20,30,40,50 and horizontal tick lines that intersect the
plotted points.

All very good, but if I change the upper y axis limit to 54.0,
(ax.set_ylim(18.0, 54.0)), it fails, plotting the ticks at some strange

Ultimately I want to uncomment the set scale to log and use this to
label semi log plots that by default are only labeled on powers of 10.
My data falls within one decade so I don't want the full 10-100 limits.

I'm rather new at matplotlib so if I'm making trivial errors please feel
free to criticize.

Dick C

from pylab import *
from matplotlib.ticker import MaxNLocator

x=[10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0]
ax.plot(array(x), array(y), 'x')
ax.set_ylim(18.0, 58.0)
ax.set_yticklabels(('10', '20','30','40','50','60','70','80','90','100'))
ax.yaxis.grid(True, linestyle='-', which='major')

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[matplotlib] Overlapping axis text Durand Python 2 11-10-2008 11:40 PM
matplotlib / legend of x-axis Frédéric Degraeve Python 0 03-26-2008 10:55 AM
Matplotlib: How to set number of ticks on an axis? Caleb Hattingh Python 2 03-31-2006 05:57 AM
MatPlotLib.MatLab troubles (how to install/run matplotlib.PyLab?) Dr. Colombes Python 3 02-23-2005 04:32 PM
AXIS jars org.apache.axis.wsi.* and org.apache.axis.transport.jms.* Java 0 02-23-2005 04:02 PM