LiErRui

绘制霍兰德人格分析

一、绘制霍兰德人格分析

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

matplotlib.rcParams[\'font.family\'] = \'SimHei\'
matplotlib.rcParams[\'font.sans-serif\'] = [\'SimHei\']
radar_labels = np.array([\'研究型\',\'艺术型\',\'社会型\',\'企业型\',\'常规型\',\'现实型\'])
Attr = 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= (\'工程师\',\'实验员\',\'艺术家\',\'推销员\',\'社会工作者\',\'记事员\')
angels = np.linspace(0,2*np.pi,Attr,endpoint = False)
data = np.concatenate((data,[data[0]]))
angels = np.concatenate((angels,[angels[0]]))

fig = plt.figure(facecolor=\'white\')
plt.subplot(111,polar = True)
plt.plot(angels,data,\'bo-\',color = \'gray\',linewidth = 0.2)

plt.plot(angels,data,\'o-\',linewidth = 1.5,alpha=0.2)
plt.fill(angels,data,alpha =0.25)
plt.thetagrids(angels*180/np.pi,radar_labels)
print(angels*180/np.pi)
plt.figtext(0.55,0.95,\'霍兰德人格分析\',ha=\'center\',size =10)
legend=plt.legend(data_labels,loc= (0.94,0.80),labelspacing=0.1)
plt.setp(legend.get_texts(),fontsize=\'small\')
plt.grid(True)
plt.savefig(\'holland_radar.JPG\')
plt.show()

运行结果

二、代码详解

1、matplotlib.pyplot.legend(*args**kwargs)[source]

作用:在图上放上图例

参数解释:

loc:int or string or pair of floats, default: 
图例所有在figure位置
prop: None or matplotlib.font_manager.FontProperties or dict
the font property字体参数
fontsize: int or float or {\'xx-small\', \'x-small\', \'small\', \'medium\', \'large\', \'x-large\', \'xx-large\'}
设置字体大小
markerscale:None or int or float

图例标记的相对大小与最初绘制的标记相比较。默认值是None,它将从中获取值 rcParams["legend.markerscale"]
markerfirst:bool
如果为True,则图例标记位于图例标签的左侧
numpoints:None or int
为线条图图例条目创建的标记点数
scatterpoints:None或int
the number of points in the legend for scatter plot
为散点图图例条目创建的标记点数
scatteryoffsets: None or int
为散点图图例条目创建的标记的垂直偏移量
frameon:None or bool
控制是否应在图例周围绘制框架
fancybox:None or bool
控制是否应在构成图例背景的FancyBboxPatch周围启用圆边
shadow:None or bool
控制是否在图例后面画一个阴影
framealpha:None or bool
控制图例框架的 Alpha 透明度
edgecolor

控制图例的背景色块边缘颜色。默认是None,这将需要从价值rcParams["legend.edgecolor"]如果"inherit",这将需要rcParams["axes.edgecolor"]

facecolor

控制图例的背景颜色。默认值是None,它将从中获取值rcParams["legend.facecolor"]如果"inherit",它将需要rcParams["axes.facecolor"]
Frame facecolor.
ncol:int or None
number of columns 设置图例分为n列展示
borderpad:int or None
图例边框的内边距
labelspacing:int or None
图例条目之间的垂直间距
handlelength:int or None
 图例句柄的长度
handleheight:int or None
图例句柄的高度
handletextpad:int or None

图例句柄和文本之间的间距

columnspacing: float或None

the spacing between columns 列间距
title:str或None
图例标题

分类:

技术点:

相关文章:

  • 2021-04-05
  • 2021-07-06
  • 2021-11-16
  • 2021-08-17
  • 2021-08-17
  • 2021-12-25
  • 2021-12-15
  • 2021-10-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2021-12-03
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案