軸の範囲を指定する

2011/2/2

Python2.5.4, matplotlib-0.98.5.2

import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,5,4,6,8,7]
plt.plot(x,y)

xmin = 0
xmax = 10
ymin = 0
ymax = 10
plt.axis([xmin, xmax, ymin, ymax])
plt.show()


y軸だけ指定

import matplotlib.pyplot as plt

x = [1,2,3,4,5,6]
y = [2,5,4,6,8,7]
plt.plot(x,y)

xmin,xmax,ymin,ymax = plt.axis()
ymin = 0
ymax = 10
plt.axis([xmin, xmax, ymin, ymax])
plt.show()