python - 如何在 python matplotlib 中设置限制范围 (xlim)?

标签 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()

chart

最佳答案

matplotlib.pyplot.xlim , matplotlib.pyplot.ylim是功能。您应该调用它们而不是分配给它们:

plt.ylim(-10,10)
plt.xlim(-10,10)

enter image description here

关于python - 如何在 python matplotlib 中设置限制范围 (xlim)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42749014/

相关文章:

matlab - 如何使用颜色图而不是纯色来填充补片对象?

r - 结合 `for loop` 和 ggplotGrob

python - 为什么无法将 Application Insights 与 Azure Function 结合使用?

QPython 错误的 android.Android()

python - 在 Python 中同时分配索引不同的列表元素

python - 如何制作非方形等高线图

r - fiddle 图形状的堆积条形图

python - 为什么列表无缘无故更改?

python - 想知道为什么 matplotlib pyplot 不会调整边距

python - Seaborn 的多个直方图