import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
fig = plt.figure()
spec = gridspec.GridSpec(nrows=2,ncols=2,figure=fig,
# hspace=2, #坐标系实例之间纵向间距
# wspace=2, #坐标系实例之间纵向间距
left=0.25,right=0.9,top=0.9,bottom=0.25 #把所有坐标实例“打包”在一起,整体伸缩/平移
)
ax1 = fig.add_subplot(spec[0,0],projection='polar')
ax2 = fig.add_subplot(spec[0,1])
ax3 = fig.add_subplot(spec[1,:])
#绘制雷达图
plt.rcParams['font.family'] = 'SimHei'
plt.rcParams['axes.unicode_minus'] = False
dim_num = 6
radians = np.linspace(0, 2 * np.pi, dim_num, endpoint=False)
radians = np.concatenate((radians, [radians[0]]))
polar_yun = np.array([33,45,10,9,4,4])
polar_yun = np.concatenate((polar_yun, [polar_yun[0]]))
polar_tong = np.array([16,14,6,8,30,33])
polar_tong = np.concatenate((polar_tong, [polar_tong[0]]))
ax1.plot(radians,polar_yun,radians,polar_tong)
# plt.polar(radians,polar_yun,radians,polar_tong)
polar_x = ['化学药','中成药','生物制品','中药颗粒','中药饮片','保健品']
polar_x = np.concatenate((polar_x, [polar_x[0]]))
angles = radians * 180/np.pi # 弧度转角度
# plt.thetagrids(angles, labels=polar_x)
ax1.fill(angles,polar_tong,radians,polar_yun,radians,alpha=0.25)
plt.show()