legend plotting help with for loop
조회 수: 6 (최근 30일)
이전 댓글 표시
hi everyone, i have the code below which works fine and plots the data i need, however the legend note only states the final loop input and shows it next to the line colour red, is there any way i can have the legend to show the 3 different line types i need thanks kyle
for i = 1 : k(1)
%loads internal forces for plotting
file_name = sprintf('internalforce_%d',i);
variable = load(file_name,'int_force');
%loads deflection for plotting
filetwo_name = sprintf('data_%d',i);
variabletwo = load(filetwo_name,'deflection');
%create a colour array for use in altering plot colours
mark = {'*-r','o-g','^-b','*-k','*-c','*-r'};
%plots the Force displacment graphs on one plot
plot(-variabletwo.deflection,-variable.int_force,mark{i});legend(filetwo_name)
%sets titles and axis for graph
xlabel(['OX axis ' lengthunits]);ylabel(['OY axis ' axialunits]);
title('Force Displacment Graph '); grid on
end
댓글 수: 0
답변 (1개)
Paulo Silva
2011년 5월 9일
Something similar to this:
hold on
mark = {'*-r','o-g','^-b','*-k','*-c','*-r'};
for i = 1 : 6
%loads internal forces for plotting
%file_name = sprintf('internalforce_%d',i);
%variable = load(file_name,'int_force');
%loads deflection for plotting
%filetwo_name = sprintf('data_%d',i);
%variabletwo = load(filetwo_name,'deflection');
%create a colour array for use in altering plot colours
%plots the Force displacment graphs on one plot
p(i)=plot(i,i,mark{i})%legend(filetwo_name)
%sets titles and axis for graph
%xlabel(['OX axis ' lengthunits]);ylabel(['OY axis ' axialunits]);
%title('Force Displacment Graph '); grid on
end
legend(p,mark)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!