matplotlib画图极坐标图/雷达图

ax方法画极坐标与雷达图,雷达图是在极坐标图基础上进行删减和增加
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
ax.plot(angle, distance, color,alpha,lw,linstyle)

1 画极坐标图(折线图)

数据准备:
值序列:distance;
角度:angle,相当于x_location;
标签:labels,相当于x轴上的标签
三者均需将第一个值加到末尾,设置闭合数据
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
ax.plot(angle, distance, color,alpha,lw,linstyle, label=):
极坐标绘制(角度,与圆心的距离)构成一点
ax.set_thetagrids(angels * 180/npy.pi, labels)
plt.legend()
df = pd.DataFrame(np.random.randint(1,20,(4,3)), index=[u'衣',u'食',u'住',u'行'], columns=[u'山东',u'陕西',u'山西'])
df = df.append(df.loc[u'衣'])   # 设置数据闭合
	山东 陕西 山西
衣	9	14	1515	15	1210	6	34	7	189	14	15

theta = np.linspace(0, 2*np.pi, 4, endpoint=False)  # 不包含2pi,否则首尾重合
theta = np.append(theta,theta[0])  # 角度闭合
fig = plt.figure()
ax = fig.add_subplot(111, polar=True) 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值