plt.show() 报错only length-1 arrays can be converted to Python scalars
时间: 2023-11-06 17:54:30 浏览: 225
根据引用\[1\]中的描述,报错"TypeError: only length-1 arrays can be converted to Python scalars"是由于在使用plt.show()函数时,传入的参数不符合要求。根据引用\[2\]中的建议,可以尝试将参数转换为长度为1的数组。具体做法是使用np.array()函数将参数转换为数组形式。例如,可以尝试将plt.show()改为plt.show(np.array(\[1\]))。这样应该可以解决报错问题。
#### 引用[.reference_title]
- *1* [TypeError: only size-1 arrays can be converted to Python scalars 报错如何解决](https://blog.csdn.net/m0_71772987/article/details/125163575)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [关于调用math.函数,报错only size-1 arrays can be converted to Python scalars的解决办法](https://blog.csdn.net/m0_62529115/article/details/126940775)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [only size-1 arrays can be converted to Python scalars和Polynomial must be 1d only](https://blog.csdn.net/qq_55387577/article/details/126559068)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文