Identifying a line in multiple plots

조회 수: 4 (최근 30일)
Charles Mitchell-Thurston
Charles Mitchell-Thurston 2022년 6월 10일
편집: Charles Mitchell-Thurston 2022년 6월 10일
I have code that plots all of my data as random colours and it works perfectly.
for t = 1:20
tempY = Sim_Graphs_Y{t,1};
txt = [num2str(t)];
plot(NewX,tempY,'Color',rand(1,3),'LineStyle','--','DisplayName',txt);
hold on
end
plot(NewX,ygraph1,'Color','r','LineStyle','-','DisplayName','Exp');
legend
savefig('weightingTEST.fig')
Is there a better way for me to be able to work out which line is which outside of just trying to match the colour as best i can?

채택된 답변

Kevin Holly
Kevin Holly 2022년 6월 10일
I made the app attached with App Designer. You could make a similar app to help you identify the selected lines. You can change the lines within the startup function.

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 6월 10일
Not sure what that means. You can set a breakpoint on the plot line and see each curve right when it's plotted.
If you want you can, with sprintf(), create a cell array of strings inside the loop that describes the parameters of each curve and then give that cell array to legend()
  댓글 수: 2
Charles Mitchell-Thurston
Charles Mitchell-Thurston 2022년 6월 10일
편집: Charles Mitchell-Thurston 2022년 6월 10일
Ahh i probably explained that badly, i just want i would like to know which line is the one closest to the solid red line. And i was wondering if there was a better way for me to be able to see which line that is outside of trying to match the colour of the line to the colour in the legend.
Image Analyst
Image Analyst 2022년 6월 10일
Not sure what "closed" means. To find the closest, compute the mean absolute deviation. There is a function mad
or
theMAD(t) = mean(abs(curve - redCurve));
and look for the min value
[minMad, indexOfMinMad] = min(theMAD)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by