matplotlib 有没有快速缩放轴的方法?
说我想要情节
import matplotlib.pyplot as plt
c= [10,20 ,30 , 40]
plt.plot(c)
它会绘制
我如何扩展x-axis快速地说,将每个值乘以5
?
一种方法是创建一个数组x axis:
x = [i*5 for i in range(len(c))]
plt.plot(x,c)
我想知道是否有一种更短的方法可以做到这一点,而无需创建列表x轴,说类似的话plt.plot(index(c)*5, c)
Use a numpy.array http://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html而不是列表,
c = np.array([10, 20, 30 ,40]) # or `c = np.arange(10, 50, 10)`
plt.plot(c)
x = 5*np.arange(c.size) # same as `5*np.arange(len(c))`
这给出:
>>> print x
array([ 0, 5, 10, 15])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)