python 画雷达图
时间: 2023-07-28 21:09:26 浏览: 118
要使用Python画雷达图,可以使用matplotlib库中的polar参数来创建极坐标图。以下是一个示例代码:
```python
import numpy as np
import matplotlib.pyplot as plt
labels = np.array(\["语文", "数学", "英语", "化学", "物理","生物","信息"\])
dataLenth = 7
data = np.array(\[83, 61, 95, 67, 76, 88, 40\])
angles = np.linspace(0, 2*np.pi, dataLenth, endpoint=False)
data = np.concatenate((data, \[data\[0\]\]))
angles = np.concatenate((angles, \[angles\[0\]\]))
labels = np.concatenate((labels, \[labels\[0\]\]))
fig = plt.figure(facecolor="white")
plt.subplot(111, polar=True)
plt.plot(angles, data, 'bo-', color='g', linewidth=2)
plt.fill(angles, data, facecolor='g', alpha=0.25)
plt.thetagrids(angles*180/np.pi, labels)
plt.grid(True)
plt.show()
```
这段代码首先定义了要显示的数据和标签,然后通过`np.linspace`函数生成角度,将数据和角度进行连接,最后使用`plt.plot`和`plt.fill`函数绘制雷达图。最后使用`plt.show()`显示图形。
#### 引用[.reference_title]
- *1* [使用python简单绘制雷达图](https://blog.csdn.net/weixin_45972980/article/details/124194614)[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* [python绘制雷达图(详细)](https://blog.csdn.net/yawei_liu1688/article/details/113058806)[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* [Python绘制雷达图](https://blog.csdn.net/pythonxuexi123/article/details/113862016)[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 ]
阅读全文