在MATLAB中为循环中的每条曲线定义特定的颜色和线型

问题描述 投票:0回答:1

通过在the previous question中将每条曲线与其自身存储的数据(即方法)相关的循环中绘制曲线,如何更改和定义新的特定颜色和线型(例如“-”)对于循环后每种方法的曲线?

figure
hold on
for m = 1:length(methods)
  prFileName = strcat(readpath,dataset, '_', methods{m}, '_PRCurve.txt');
  R = load(prFileName);
  precision = R(:, 1);
  recall = R(:, 2);
  plot(recall, precision,'color',methods_colors(m,:),'linewidth',2);    
end
axis([0 1 0 1]);
hold off
grid on;
box on;
legend('methode one','method two')
xlabel('Recall','fontsize',12);
ylabel('Precision','fontsize',12);
set(gcf,'color','w');  %Background color
ax = gca;  % current axes
ax.GridLineStyle='-';
ax.GridAlpha=0.7;
ax.XAxis.LineWidth=4;
ax.YAxis.LineWidth=4;
Grid.LineWidth = 3;
set(gca,'FontName','Arial','FontWeight','bold');

为了方便实施,可以将每种方法的数据都假定为rand(256x2)

matlab for-loop matlab-figure
1个回答
0
投票

您可以使用lines_obj = findobj(h, 'Type', 'Line')set(lines_obj, ...

© www.soinside.com 2019 - 2024. All rights reserved.