module 'matplotlib.pyplot' has no attribute 'yaxis'. Did you mean: 'axis'怎么回事
时间: 2023-07-06 22:07:14 浏览: 321
这个问题可能是因为您使用了错误的方法名。在Matplotlib中,`yaxis`并不是一个独立的函数/方法,而是`plt.gca().yaxis`的属性之一。您可以尝试使用以下代码来设置y轴标签的属性:
```python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.ylabel('y-axis label')
plt.gca().yaxis.set_label_coords(-0.1, 0.5) # 设置y轴标签的位置
plt.show()
```
这里,`plt.gca()`获取当前的坐标轴,然后我们可以通过其`yaxis`属性来设置y轴标签的位置等属性。
相关问题
AttributeError: module 'matplotlib.pyplot' has no attribute 'dates'. Did you mean: 'axes'?
AttributeError: module 'matplotlib.pyplot' has no attribute 'dates'. 这个错误是因为在matplotlib.pyplot模块中没有名为'dates'的属性。你可能想要使用的是'matplotlib.dates'模块中的某个属性。你可以尝试使用'matplotlib.dates'来替代'matplotlib.pyplot.dates'。
AttributeError: module 'matplotlib.pyplot' has no attribute 'ylable'. Did you mean: 'table'?
AttributeError: module 'matplotlib.pyplot' has no attribute 'ylable'. Did you mean: 'table'?
这个错误是由于在使用matplotlib.pyplot时拼写错误导致的。正确的拼写应该是'ylabel'而不是'ylable'。所以请检查你的代码,将'ylable'改为'ylabel'即可解决该问题。
阅读全文
相关推荐
















