两个小工具,一个归一化,一个六度图

import numpy as np
import matplotlib.pyplot as plt


def noramlization(data):
    minVals = data.min(0)
    maxVals = data.max(0)
    ranges = maxVals - minVals
    normData = np.zeros(np.shape(data))
    m = data.shape[0]
    normData = data - np.tile(minVals, (m, 1))
    normData = normData/np.tile(ranges, (m, 1))
    return normData, ranges, minVals


x = np.array([[78434.0829, 26829.86612], [78960.4042, 26855.13451], [72997.8308, 26543.79201],
              [74160.2849, 26499.56629], [75908.5746, 26220.11996], [74880.6989, 26196.03995],
              [74604.7169, 27096.87862], [79547.6796, 25986.68579], [74997.7791, 24021.50132],
              [74487.4915, 26040.18441], [77134.2636, 24647.274],   [74975.2792, 24067.31441],
              [76013.5305, 24566.02273], [79191.518,  26840.29867], [80653.4589, 25937.22248],
              [79185.9935, 26996.18228], [74426.881,  24227.71439], [73246.4295, 26561.59268],
              [77963.1478, 25580.05298], [74469.8778, 26082.15448], [81372.3787, 26649.69232],
              [76826.8262, 24549.77367], [77774.2608, 25999.96037], [79673.1361, 25229.04353],
              [75251.7951, 24902.72185], [78458.073,  23924.15117], [82247.5439, 29671.33493],
              [82041.2247, 27903.34268], [80083.2029, 28692.35517], [80962.0043, 28519.81002],
              [79799.8328, 28740.27736], [80743.9947, 28862.75402], [80888.449,  29724.53706],
              [81768.4638, 30180.20618], [80283.8783, 30417.55057], [79460.7078, 29092.52867],
              [75514.1202, 28071.73721], [80595.5945, 30292.25917], [80750.4876, 29651.32254],
              [80020.662,  30023.70025], [82992.3395, 29466.83067], [80185.5946, 29943.15481],
              [81854.6163, 29846.18257], [81526.4017, 30218.27078], [79174.5312, 29960.69999],
              [78112.3051, 26467.57545], [80262.4121, 29340.23218], [81284.9734, 28257.71529],
              [81928.9905, 28752.84811], [80739.2727, 29288.85126], [83135.3435, 30223.4974],
              [83131.8223, 29049.10112], [82549.9076, 28910.15209], [81574.0822, 28326.55367],
              [80507.399,  28553.56851], [82956.2103, 29157.62372], [81909.7132, 29359.24497],
              [80893.5603, 29326.64155], [82520.1272, 30424.96703], [82829.8548, 31062.24418],
              [80532.1495, 29198.10407], [80112.7963, 29143.47905], [81175.0882, 28443.10574]])

newgroup, _, _ = noramlization(x)
newdata = newgroup
plt.scatter(x[:, 0], x[:, 1], marker='*', c='r', s=24)
plt.show()
print(len(x[:, 0]))
print(len(x[:, 1]))
# print(newdata)

#HollandRadarDraw.py
from numpy import array,shape,arange
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family']='SimHei'
radar_labels = np.array(['研究型(I)','艺术型(A)','社会型(S)',\
                         '企业型(E)','常规型(C)','现实型(R)']) #雷达标签
nAttr = 6
data = np.array([[0.40, 0.32, 0.35, 0.30, 0.30, 0.88],
                 [0.85, 0.35, 0.30, 0.40, 0.40, 0.30],
                 [0.43, 0.89, 0.30, 0.28, 0.22, 0.30],
                 [0.30, 0.25, 0.48, 0.85, 0.45, 0.40],
                 [0.20, 0.38, 0.87, 0.45, 0.32, 0.28],
                 [0.34, 0.31, 0.38, 0.40, 0.92, 0.28]]) #数据值
data_labels = ('艺术家', '实验员', '工程师', '推销员', '社会工作者','记事员')
angles = np.linspace(0, 2*np.pi, nAttr, endpoint=False)
data = np.concatenate((data, [data[0]]))
angles = np.concatenate((angles, [angles[0]]))
fig = plt.figure(facecolor="white")
plt.subplot(111, polar=True)
plt.plot(angles,data,'o-', linewidth=1, alpha=0.2)
plt.fill(angles,data, alpha=0.25)
plt.thetagrids(angles*180/np.pi, radar_labels)
plt.figtext(0.52, 0.95, 'Wuhan University', ha='center', size=20)
legend = plt.legend(data_labels, loc=(0.94, 0.80), labelspacing=0.1)
plt.setp(legend.get_texts(), fontsize='large')
plt.grid(True)
plt.savefig('holland_radar.jpg')
plt.savefig('holland_radar.svg',format='svg')
plt.show()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值