大一做作业时遇到的问题,求解

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams["font.family"]="SimHei"
matplotlib.rcParams["font.sans-serif"] = ["SimHei"]
labels = np.array(["IQ智商","EQ情商","FQ财商","LQ领导商","AQ逆境商"])
nAttr = 5
data = np.array([139,90,120,80,200])
angles = np.linspace(0,2*np.pi,nAttr,endpoint=False)
data = np.concatenate((data,[data[0]]))
angles = np.concatenate((angles,[angles[0]]))
labels=np.concatenate((labels,[labels[0]]))  #对labels进行封闭
fig = plt.figure(facecolor="white")
plt.subplot(111,polar=True)
plt.plot(angles,data,"bo-",color ="g",linewidth=2)
plt.fill(angles,data,facecolor="g",alpha=0.25)
plt.thetagrids(angles*180/np.pi,labels)
plt.figtext(0.52,0.95,"商数雷达图",ha="center")
plt.grid(True)
plt.show()

建议将代码直接拷到论坛上来,我们可以帮你实时测试

 修改一下字符串的编码

# coding:utf-8 
import numpy as np
import matplotlib.pyplot as plt
labels = np.array(['IQ智商''EQ情商''FQ财商''LQ领导商''AQ逆境商'])
dataLenth = 5
data = np.array([139,90,120,80,200])
angles = np.linspace(0,2*np.pi,dataLenth,endpoint=False)
data = np.concatenate((data,[data[0]]))
angles = np.concatenate((angles,[angles[0]]))
fig = plt.figure()
ax = fig.add_subplot(111,polar=True)
ax.plot(angles,data,'bo-',linewidth=2)
ax.fill(angles,data,facecolor='r',alpha=0.25)
ax.set_thetagrids(angles * 180/np.pi, labels, fontproperties="SimHei")
ax.set_title(u'商数雷达图',va='bottom',fontproperties='SimHei')
#ax.rilm(0,200)
ax.grid(True)
plt.show()

输出

 

import numpy as np
import matplotlib.pyplot as plt
labels = np.array(['IQ智商''EQ情商''FQ财商''LQ领导商''AQ逆境商'])
dataLenth = 5
data = np.array([139,90,120,80,200])
angles = np.linspace(0,2*np.pi,dataLenth,endpoint=False)
data = np.concatenate((data,[data[0]]))
angles = np.concatenate((angles,[angles[0]]))
fig = plt.figure()
ax = fig.add_subplot(111,polar=True)
ax.plot(angles,data,'bo-',linewidth=2)
ax.fill(angles,data,facecolor='r',alpha=0.25)
ax.set_thetagrids(angles * 180/np.pi, labels, fontproperties="SimHei")
ax.set_title("商数雷达图",va='bottom',fontpeoperties="SimHei")
ax.set_rilm(0,200)
ax.grid(True)
plt.show()

 

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632