AttributeError: module 'matplotlib.pyplot' has no attribute 'rcparams'
时间: 2023-09-14 22:07:38 浏览: 90
AttributeError: module 'tensorflow.compat.v1' has no attribute '
This error occurs when you try to access the attribute 'rcparams' from the 'matplotlib.pyplot' module, but it does not exist.
The correct attribute to use is 'rcParams' (note the capitalization of the letter 'P'). So, instead of using 'matplotlib.pyplot.rcparams', you should use 'matplotlib.pyplot.rcParams'.
Here's an example of how to use it:
```
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [10, 5] # Set the default figure size
# Plot a simple line graph
x = [1, 2, 3, 4, 5]
y = [10, 20, 30, 40, 50]
plt.plot(x, y)
plt.show()
```
In this example, we set the default figure size using the 'rcParams' attribute of the 'pyplot' module.
阅读全文