current position:Home>Radar chart of Python data display

Radar chart of Python data display

2022-02-02 14:44:29 Rocky_ ninety-six

Python Radar chart of data display

Simple example
demand : Radar chart method to verify Holland's personality analysis
Input : Survey data of various occupational groups combined with their interests
Output : Radar map
Use the library :matplotlib+numpy
Code

import numpy as np
import matplotlib.pyplot as plt
import matplotlib

matplotlib.rcParams['font.family'] = 'SimHei'
radar_labels = np.array([' Research type ', ' Artistic type ', ' Social type ', ' Enterprise type ', ' Conventional type ', ' Realistic '])
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=(' The artist ',' Experimenter ',' The engineer ',' salesman ',' Social workers ',' Recorder ')
angles=np.linspace(0,2*np.pi,nAttr,endpoint=False)

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,' Holland personality analysis ',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.show()

The result is shown in Fig.
 Insert picture description here

copyright notice
author[Rocky_ ninety-six],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/02/202202021444276372.html

Random recommended