matplotlib 雷达图可视化

import random
from matplotlib import pyplot as plt
import numpy as np

def academic_level_img():
max_list = [405, 330, 165, 180, 120, 135]#这些值可以修改
score = [10.9134,5,4,5.2587,4.8392,6.0005]#这些值可以修改
new_score = []
for a, b in zip(score, max_list):
new_score.append(a / b)
end_score = []
max_new_score = max(new_score)
for x in new_score:
c = x * (1 / max_new_score)
if c <= 0.1 and c > 0:
c = c + random.random() * 0.1
c = c * 2.5
end_score.append©
criterion = end_score + [end_score[0]] # 基准雷达图
angles = np.linspace(0, 2 * np.pi, 6, endpoint=False)
angles = np.concatenate((angles, [angles[0]]))
fig = plt.figure(figsize=(5, 5)) # 创建画板并填充颜色
ax = fig.add_subplot(111, polar=True, ) # 设置坐标为极坐标
# 绘制三个五边形
floor, ceil = 0, 2.5
labels = np.array([‘防御力’, ‘攻击力’, ‘暴击’, ‘攻速’, ‘最大生命’, ‘物防’])
labels = np.concatenate((labels, [labels[0]]))
# 绘制五边形的循环
for i in np.arange(floor, ceil + 0.5, 0.5):
ax.plot(angles, [i] * (7), ‘-’, lw=0.5, color=‘black’)
for i in range(6):
ax.plot([angles[i], angles[i]], [floor, ceil], ‘-’, lw=0.5, color=‘black’)
# 绘制雷达图
ax.plot(angles, criterion, ‘o-’, lw=2, alpha=1, color=’#1d953f’)
ax.fill(angles, criterion, facecolor=’#1d953f’, alpha=0.5) # 填充
ax.set_thetagrids(angles * 180 / np.pi, labels, fontproperties=‘SimHei’, fontsize=12)
ax.spines[‘polar’].set_visible(False) # 不显示极坐标最外的圆形
ax.set_theta_zero_location(‘N’) # 设置极坐标的起点(即0度)在正上方向
ax.grid(False) # 不显示分隔线
ax.set_yticks([]) # 不显示坐标间隔
ax.set_title(‘剑圣\n’, va=‘bottom’, fontproperties=‘SimHei’, fontsize=20, horizontalalignment=‘center’)
plt.subplots_adjust(left=0.1, right=0.9, bottom=0.1, top=0.8)
plt.show()

if name == ‘main’:
academic_level_img()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值