'Rectangle' object has no property 'normed'
时间: 2023-06-23 14:58:05 浏览: 55
这个错误是因为在 matplotlib 库的版本更新后,`normed` 这个参数已经被替换为 `density` 参数。所以,如果你使用的是新版本的 matplotlib 库,需要将 `normed=True` 改为 `density=True`。
所以,正确的代码应该是:
```
df.counts.plot(kind='hist', bins=30, density=True)
```
这样就可以解决这个错误。
相关问题
AttributeError: 'Rectangle' object has no property 'normed'
这个错误通常是因为您使用的是Matplotlib的版本问题。在最新版本的Matplotlib中,`normed`被替换为`density`。因此,如果您使用的是最新版本的Matplotlib,则需要将代码中的`normed`替换为`density`。
以下是一个简单的例子,可以帮助您解决这个问题:
```python
import matplotlib.pyplot as plt
import numpy as np
# 创建一些随机数据
data = np.random.normal(size=1000)
# 绘制直方图
plt.hist(data, density=True, alpha=0.5)
# 显示图形
plt.show()
```
在这个例子中,我们使用了`density=True`,而不是`normed=True`。这是因为在最新版本的Matplotlib中,`normed`被替换为`density`,用于指示是否将直方图归一化为概率密度。通过将`density`设置为True,我们将直方图归一化为概率密度。
希望这个回答能够帮助您!
'Rectangle' object has no property 'fit'
This error message usually occurs when you are trying to use the 'fit' property on an object that does not have it. The 'fit' property is usually used in machine learning libraries such as TensorFlow or Keras to resize an image to a specified size.
If you are trying to use the 'fit' property on a 'Rectangle' object, it is likely that you are using the wrong library or method. 'Rectangle' objects are usually found in graphics libraries like Pygame or PIL (Python Imaging Library), and they do not have a 'fit' property.
To fix the error, you should check the documentation of the library you are using to see if there is a different method that you can use to achieve the same result. Alternatively, you may need to modify your code to use a different object or library that has the 'fit' property.
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)