首页 文章

Matlab,某些行的gplot自定义线宽,但不是全部

提问于
浏览
0

在过去,有人提出了一个关于在gplot中自定义线宽的问题(参见In MatLab, how to adjust the line width drawn by the function 'gplot'?) . 我正在处理一个稍微复杂的版本,这使我无法使用那里给出的解决方案 . 因此,我想问一下如何做到以下几点:我想调整一些gplot调用的行宽,而不是其他调用 . 我正在多次调用gplot并使用hold on在一个图中绘制它们 . 我试图绘制一个图形,有多种类型的边(A和A2) . 还有k路径 . 我目前正在使用以下代码:

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 回答

  • 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)
    

相关问题