How to set constant y-axis scale value

Hello,

I am quite new in matplotlib, I am now facing a quite simple problem but
have no idea to solve. I just want set the y axis scale to value 100, which
means in the image, the y axis is always of scale 100, because the points in
my image indicates the percentage value(for example, 20%, 87%) which will
never exceed 100.

So, How to set the y axis scale to constant value 100 ?? It's really hard to
find a answer from internet.

···

--
View this message in context: http://old.nabble.com/How-to-set-constant-y-axis-scale-value-tp28387748p28387748.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

melloncx wrote:

Hello,

I am quite new in matplotlib, I am now facing a quite simple problem but
have no idea to solve. I just want set the y axis scale to value 100, which
means in the image, the y axis is always of scale 100, because the points in
my image indicates the percentage value(for example, 20%, 87%) which will
never exceed 100.

So, How to set the y axis scale to constant value 100 ?? It's really hard to
find a answer from internet.

If you are using the pyplot interface, then maybe what you want is the ylim function:

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.ylim

Eric

Give this a shot:
# ----
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(20)
y = np.random.randn(20)
y = y/y.max() * 100

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y,'ko', mfc='none')

# you can do this:
ax.set_ylim([0,100])

# or something like this:
ax.set_ylim(ymin=0, ymax=100)
plt.show()

···

-----Original Message-----
From: melons [mailto:xichen@…3082…]
Sent: Wednesday, April 28, 2010 5:14 AM
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] How to set constant y-axis scale value

Hello,

I am quite new in matplotlib, I am now facing a quite simple problem but
have no idea to solve. I just want set the y axis scale to value 100,
which
means in the image, the y axis is always of scale 100, because the points
in
my image indicates the percentage value(for example, 20%, 87%) which will
never exceed 100.

So, How to set the y axis scale to constant value 100 ?? It's really hard
to
find a answer from internet.