初识 pyhton - 画雷达图

import matplotlib.pyplot as plt
import numpy as np

# 雷达图
plt.figure()
dataLenth = 5       #把整个圆切成5份;
angles = np.linspace(0, 2*np.pi, dataLenth, endpoint=False)         #角度设置
plt.rcParams['font.sans-serif'] = 'SimHei'      #字体设置

labels = ['生存', '输出', '团战', 'KDA', '发育']
data = [2, 3.5, 4, 4.5, 5]

#闭合:
data = np.concatenate((data, [data[0]]))        #一次完成多个数组的拼接
angles = np.concatenate((angles, [angles[0]]))

plt.polar(angles, data, color='r', marker='o')      #做极坐标系
plt.xticks(angles, labels)          # 刻度设置
plt.title('英雄联盟战绩')
plt.show()

效果图如下:

初识 pyhton - 画雷达图_第1张图片

你可能感兴趣的:(Python)