如何修复 Matplotlib 'AttributeError: module matplotlib.pyplot' has no attribute 'yrange'
问题:
你正在尝试使用类似这样的代码设置 matplotlib 绘图的 Y 轴范围
matplotlib_ylim_example.py
plt.yrange([0.0, 10.0])但你看到类似这样的错误消息:
matplotlib_yrange_error.txt
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-aa38a78ab5d7> in <module>
12 plt.xscale('log')
13 plt.grid(True, which="both")
---> 14 plt.yrange([0.0, 70.])
15
AttributeError: module 'matplotlib.pyplot' has no attribute 'yrange'解决方案
你需要使用 ylim 因为 yrange 不存在!等效的调用是:
matplotlib_ylim_fix.py
plt.ylim([0.0, 10.0])Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow