使用polar()函数绘制霍兰德职业兴趣测试结果的雷达图
时间: 2024-09-20 09:13:42 浏览: 138
在Python中,`matplotlib`库的`polar()`函数主要用于创建极坐标图,这非常适合展示霍兰德职业兴趣测试等基于六个维度(通常是现实主义、研究型、艺术型、社会型、企业型和常规型)的数据。这种图形通常称为六边形雷达图或霍兰德六角图。
首先,你需要准备一组数据,每条记录表示一个人在这六个兴趣领域的得分。然后,你可以按照以下步骤绘制雷达图:
```python
import matplotlib.pyplot as plt
from matplotlib.collections import PolarArcCollection
def polar_radar_chart(data):
# 数据格式示例:data = {'Realism': score1, 'Investigative': score2, ...}
categories = list(data.keys())
angles = [n / float(len(categories)) * 2 * np.pi for n in range(len(categories))]
values = data.values()
fig, ax = plt.subplots(subplot_kw=dict(polar=True))
ax.set_yticklabels([])
ax.set_xticks(angles[:-1])
ax.set_xticklabels(categories)
# 创建极坐标线
polygon = PolarArcCollection(values, linewidth=1, edgecolor='black', closed=True)
ax.add_collection(polygon)
# 添加中心圆
circle = Circle((0.5, 0.5), 0.5, ec='white', fc='none')
ax.add_artist(circle)
# 自动调整范围
ax.set_ylim(0, max(values) + 0.1)
plt.show()
# 调用函数并传入霍兰德兴趣测试得分数据
polar_radar_chart(your_holland_interest_scores)
```
阅读全文
相关推荐


















