2013-06-28 65 views
0

過去,有人提出了有關定製gplot中線寬的問題(請參閱In MatLab, how to adjust the line width drawn by the function 'gplot'?)。我正在處理一個稍微複雜的版本,這阻止了我使用那裏給出的解決方案。因此,我想問如何做到以下幾點:我想調整一些gplot調用的線寬,而不是其他的調用。我就是多次撥打gplot,然後用一個數字來繪製它們。我正在試圖繪製一個圖形,使用多種類型的邊(A和A2)。其中有k條路徑。我目前使用下面的代碼:Matlab,gplot爲某些行定製線寬,但不是全部

figure 
hold on 
gplot(A,coor,'k*:') 
gplot(A2,coor,'k-') 
plot(coor(T,1),coor(T,2),'k.','MarkerSize',20) 
plot(coor(T,1),coor(T,2),'bo','MarkerSize',20) 
% a line where I define my own colors (not shown, since not relevant) 
set(gca,'ColorOrder',colors) 
hold all 
for i=1:k 
    gplot(Path,coor) 
end 
hold off 

但我想用一個更大的線寬繪製的路徑,同時保持A和A2在標準線寬1.

有人可以幫助我?非常感謝你!

回答

1

你可以得到軸的孩子之前並添加額外的行之後,只設置了新的有較大的線寬:

figure 
hold on 
gplot(A,coor,'k*:') 
gplot(A2,coor,'k-') 
plot(coor(T,1),coor(T,2),'k.','MarkerSize',20) 
plot(coor(T,1),coor(T,2),'bo','MarkerSize',20) 
ChildrenBefore=get(gca,'children'); 
% a line where I define my own colors (not shown, since not relevant) 
set(gca,'ColorOrder',colors) 
hold all 
for i=1:k 
    gplot(Path,coor) 
end 
hold off 
ChildrenAfter=get(gca,'children'); 
NewChildren=setdiff(ChildrenAfter,ChildrenBefore); 
set(intersect(findall(gcf,'type','line'),NewChildren),'LineWidth',5) 
+0

非常感謝你。這完美的作品! – dro

+0

@dro,請將此問題標記爲答案,這就是SO的工作原理! – macduff

相關問題