利用Matlab繪制好看的弦圖_第1頁(yè)
利用Matlab繪制好看的弦圖_第2頁(yè)
利用Matlab繪制好看的弦圖_第3頁(yè)
利用Matlab繪制好看的弦圖_第4頁(yè)
利用Matlab繪制好看的弦圖_第5頁(yè)
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

第利用Matlab繪制好看的弦圖obj.chordTable.Variables=obj.dataMat;

obj.chordTable.Properties.VariableNames=obj.colName;

obj.chordTable.Properties.RowNames=obj.rowName;

helpchordChart

functionobj=draw(obj)

obj.ax.XLim=[-1.38,1.38];

obj.ax.YLim=[-1.38,1.38];

obj.ax.XTick=[];

obj.ax.YTick=[];

obj.ax.XColor='none';

obj.ax.YColor='none';

obj.ax.PlotBoxAspectRatio=[1,1,1];

%計(jì)算繪圖所用數(shù)值

tDMat=obj.chordTable.Variables;

tDFrom=obj.chordTable.Properties.RowNames;

tDTo=obj.chordTable.Properties.VariableNames;

tDMatUni=tDMat-min(min(tDMat));

tDMatUni=tDMatUni./max(max(tDMatUni));

sep1=1/20;

sep2=1/40;

ratioF=sum(tDMat,2)./sum(tDMat,[1,2]);

ratioF=[0,ratioF'];

ratioT=[0,sum(tDMat,1)./sum(tDMat,[1,2])];

sepNumF=size(tDMat,1);

sepNumT=size(tDMat,2);

sepLen=pi*(1-2*sep1)*sep2;

baseLenF=(pi*(1-sep2)-(sepNumF-1)*sepLen);

baseLenT=(pi*(1-sep2)-(sepNumT-1)*sepLen);

tColor=[6196137;7610386]./255;

%繪制下方方塊

fori=1:sepNumF

theta1=2*pi-pi*sep1/2-sum(ratioF(1:i))*baseLenF-(i-1)*sepLen;

theta2=2*pi-pi*sep1/2-sum(ratioF(1:i+1))*baseLenF-(i-1)*sepLen;

theta=linspace(theta1,theta2,100);

X=cos(theta);Y=sin(theta);

obj.squareFHdl(i)=fill([1.05.*X,1.15.*X(end:-1:1)],[1.05.*Y,1.15.*Y(end:-1:1)],...

tColor(1,:),'EdgeColor','none');

theta3=(theta1+theta2)/2;

FHdl(i)=text(cos(theta3).*1.28,sin(theta3).*1.28,tDFrom{i},'FontSize',12,'FontName','Arial',...

'HorizontalAlignment','center','Rotation',-(1.5*pi-theta3)./pi.*180);

obj.RTickFHdl(i)=plot(cos(theta).*1.17,sin(theta).*1.17,'Color',[0,0,0],'LineWidth',.8,'Visible','off');

%繪制上方放塊

forj=1:sepNumT

theta1=pi-pi*sep1/2-sum(ratioT(1:j))*baseLenT-(j-1)*sepLen;

theta2=pi-pi*sep1/2-sum(ratioT(1:j+1))*baseLenT-(j-1)*sepLen;

theta=linspace(theta1,theta2,100);

X=cos(theta);Y=sin(theta);

obj.squareTHdl(j)=fill([1.05.*X,1.15.*X(end:-1:1)],[1.05.*Y,1.15.*Y(end:-1:1)],...

tColor(2,:),'EdgeColor','none');

theta3=(theta1+theta2)/2;

THdl(j)=text(cos(theta3).*1.28,sin(theta3).*1.28,tDTo{j},'FontSize',12,'FontName','Arial',...

'HorizontalAlignment','center','Rotation',-(.5*pi-theta3)./pi.*180);

obj.RTickTHdl(j)=plot(cos(theta).*1.17,sin(theta).*1.17,'Color',[0,0,0],'LineWidth',.8,'Visible','off');

colorFunc=colorFuncFactory(flipud(summer(50)));

%繪制弦

fori=1:sepNumF

forj=sepNumT:-1:1

theta1=2*pi-pi*sep1/2-sum(ratioF(1:i))*baseLenF-(i-1)*sepLen;

theta2=2*pi-pi*sep1/2-sum(ratioF(1:i+1))*baseLenF-(i-1)*sepLen;

theta3=pi-pi*sep1/2-sum(ratioT(1:j))*baseLenT-(j-1)*sepLen;

theta4=pi-pi*sep1/2-sum(ratioT(1:j+1))*baseLenT-(j-1)*sepLen;

tRowV=tDMat(i,:);tRowV=[0,tRowV(end:-1:1)./sum(tRowV)];

tColV=tDMat(:,j)';tColV=[0,tColV./sum(tColV)];

%貝塞爾曲線斷點(diǎn)計(jì)算

theta5=(theta2-theta1).*sum(tRowV(1:(sepNumT+1-j)))+theta1;

theta6=(theta2-theta1).*sum(tRowV(1:(sepNumT+2-j)))+theta1;

theta7=(theta3-theta4).*sum(tColV(1:i))+theta4;

theta8=(theta3-theta4).*sum(tColV(1:i+1))+theta4;

tPnt1=[cos(theta5),sin(theta5)];

tPnt2=[cos(theta6),sin(theta6)];

tPnt3=[cos(theta7),sin(theta7)];

tPnt4=[cos(theta8),sin(theta8)];

ifj==sepNumT,obj.thetaSetF(i,1)=theta5;end

obj.thetaSetF(i,j+1)=theta6;

ifi==1,obj.thetaSetT(1,j)=theta7;end

obj.thetaSetT(i+1,j)=theta8;

%計(jì)算曲線

tLine1=bezierCurve([tPnt1;0,0;tPnt3],200);

tLine2=bezierCurve([tPnt2;0,0;tPnt4],200);

tline3=[cos(linspace(theta6,theta5,100))',sin(linspace(theta6,theta5,100))'];

tline4=[cos(linspace(theta7,theta8,100))',sin(linspace(theta7,theta8,100))'];

obj.chordMatHdl(i,j)=fill([tLine1(:,1);tline4(:,1);tLine2(end:-1:1,1);tline3(:,1)],...

[tLine1(:,2);tline4(:,2);tLine2(end:-1:1,2);tline3(:,2)],...

colorFunc(tDMatUni(i,j)),'FaceAlpha',.3,'EdgeColor','none');

iftDMat(i,j)==0

set(obj.chordMatHdl(i,j),'Visible','off')

end

%繪制刻度線

tX=[cos(obj.thetaSetF(i,:)).*1.17;cos(obj.thetaSetF(i,:)).*1.19;nan.*ones(1,sepNumT+1)];

tY=[sin(obj.thetaSetF(i,:)).*1.17;sin(obj.thetaSetF(i,:)).*1.19;nan.*ones(1,sepNumT+1)];

obj.thetaTickFHdl(i)=plot(tX(:),tY(:),'Color',[0,0,0],'LineWidth',.8,'Visible','off');

forj=1:sepNumT

tX=[cos(obj.thetaSetT(:,j)').*1.17;cos(obj.thetaSetT(

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論