【发布时间】:2017-08-02 14:32:59
【问题描述】:
为什么 matplotlib.pyplot.xlim() 方法在下面的示例中不起作用?
import matplotlib.pyplot as plt
l = [0,0.2,0.4,0.6,0.8,1.0]
plt.plot(l,l)
plt.xlim = (-10,10)
plt.show()
【问题讨论】:
标签: python matplotlib plot
为什么 matplotlib.pyplot.xlim() 方法在下面的示例中不起作用?
import matplotlib.pyplot as plt
l = [0,0.2,0.4,0.6,0.8,1.0]
plt.plot(l,l)
plt.xlim = (-10,10)
plt.show()
【问题讨论】:
标签: python matplotlib plot
matplotlib.pyplot.xlim, matplotlib.pyplot.ylim 是函数。您应该调用它们而不是分配给它们:
plt.ylim(-10,10)
plt.xlim(-10,10)
【讨论】:
plt.xlim 是一个函数。无需更改此函数,您需要通过使用相应的限制调用它来使用它。
plt.xlim((-10,10))
【讨论】: