numpy 1.20.0 对应的matplotlib版本
时间: 2023-08-05 14:02:49 浏览: 185
NumPy 1.20.0 版本与 Matplotlib 3.3.3 版本兼容。您可以使用以下命令安装 Matplotlib 3.3.3 版本:
```
pip install matplotlib==3.3.3
```
或者使用以下命令升级已安装的 Matplotlib 版本:
```
pip install --upgrade matplotlib
```
相关问题
D:\pythonProject1\main.py:144: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.imshow(cm, cmap=plt.cm.Blues) D:\pythonProject1\main.py:154: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.show() D:\pythonProject1\main.py:185: DeprecationWarning: `np.str` is a deprecated alias for the builtin `str`. To silence this warning, use `str` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.str_` here. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations y_true = y_test[np.arange(y_test.shape[0]), y.astype(np.str)] Traceback (most recent call last): File "D:\pythonProject1\main.py", line 185, in <module> y_true = y_test[np.arange(y_test.shape[0]), y.astype(np.str)] IndexError: arrays used as indices must be of integer (or boolean) type
这是一个Python程序运行时出现的警告和异常。警告信息提示FigureCanvas对象将在未来版本中不再支持属性required_interactive_framework,而异常信息则指出索引数组y的数据类型必须是整数或布尔类型。
警告信息可以忽略,因为它只是提醒这个属性即将被删除,不会影响程序的执行。但是,异常信息需要解决。根据异常信息,可以看出y数组的数据类型不正确,需要将其转换为整数类型。可以使用astype()函数将y数组的数据类型转换为整数类型,例如:
```
y_true = y_test[np.arange(y_test.shape[0]), y.astype(int)]
```
这样就可以避免这个异常了。另外,还可以将代码中的np.str改为str,以避免出现DeprecationWarning警告。
阅读全文