登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
请教王老师,数据只有10种化学组分,但是图例中出现11个颜色,且在pie命令中输入colors语句会报错,无法自定义颜色,附上我的程序及图,谢谢老师。
fn=r'F:\test\PM.txt'
ncol = numasciicol(fn)
nrow = numasciirow(fn)
a = asciiread(fn,shape=(nrow,ncol))
axes(position=[0.07,0.5,0.3,0.3])
x = a[:,0]
size = 0.28
patches,=pie(x, startangle=90,radius=1, color=[(0,255,255),(0,0,255),(94,114,255),(255,128,0),(255,0,0),(255,128,128),(0,255,0),(255,255,0),(194,61,22),(0,0,187)],\
wedgeprops=dict(edgecolor='w',linewidth=0.1,width=1))
#title('Pie chart')
text(-1,0.8,'(a)',fontsize=28)
legend(patches, [r'$Cl^-$',r'$SO_4^{2-}$',r'$NO_3^-$',r'$Na^+$',r'$NH_4^+$',r'$K^+$',r'$Mg^{2+}$',r'$Ca^{2+}$',r'$OC$',r'$EC$'], loc='custom', x=0.8, y=0.38,frameon=False,fontsize=28,bold='Ture')
axes(position=[0.45,0.5,0.3,0.3])
x2 = a[:,1]
size = 0.28
pie(x2, startangle=90, radius=1, color=[(0,255,255),(0,0,255),(94,114,255),(255,128,0),(255,0,0),(255,128,128),(0,255,0),(255,255,0),(194,61,22),(0,0,187)],wedgeprops=dict(edgecolor='w',linewidth=0.1,width=1))
text(-1,0.8,'(b)',fontsize=28)
axes(position=[0.07,0.15,0.3,0.3])
data1 = a[:,2]
size = 0.28
pie(data1, startangle=90, radius=1, color=[(0,255,255),(0,0,255),(94,114,255),(255,128,0),(255,0,0),(255,128,128),(0,255,0),(255,255,0),(194,61,22),(0,0,187)],wedgeprops=dict(edgecolor='w',linewidth=0.1,width=1))
text(-1,0.8,'(c)',fontsize=28)
axes(position=[0.45,0.15,0.3,0.3])
x4 = a[:,3]
size = 0.28
pie(x4, startangle=90, radius=1, color=[(0,255,255),(0,0,255),(94,114,255),(255,128,0),(255,0,0),(255,128,128),(0,255,0),(255,255,0),(194,61,22),(0,0,187)],wedgeprops=dict(edgecolor='w',linewidth=0.1,width=1))
text(-1,0.8,'(d)',fontsize=28)
|