Question on plots i,e different line properties
조회 수: 3 (최근 30일)
이전 댓글 표시
I am plotting a 2-D matrix using only one command
colorlinestyle1 = {'r-*','g-*','b-*','k-*','m-*','c-*','r-+','g-+','b-+','k-+','m-+','c-+','r-<','g-<','b-<','k-<','m-<','c-<'};
for i=1:1:size(z1,2)-1 figure{i} plot(a5(z1(i):(z1(i+1)-1),5:20)',colorlinestyle1{1:size(z1(i):(z1(i+1)-1))}); end
In the 'For' loop each time I execute the loop a new figure is opened, and on each figure I have around 2 to 12 different lines depending on the value of 'i' . When I try to plot using the above command all the lines are showing in same format i,e "r-*" . I wish to have different format for different lines in a particular figure window. I also want to keep the ordering of the line format same i,e they should follow the order of 'colorstyle1' variable
댓글 수: 0
답변 (2개)
Honglei Chen
2012년 10월 31일
You can use LineStyleOrder and ColorOrder to achieve the combination between color and line style. However, I'm not aware an interface to define an order markers.
댓글 수: 0
Jonathan Epperl
2012년 10월 31일
Easiest would probably be to use an additional for-loop to fill figure{i}. Had you formatted your code I would have maybe been able to use your variables, but so I'll give you a general example:
colorlinestyle1 = {'r-*','g-*','b-*','k-*','m-*','c-*','r-+','g-+','b-+','k-+','m-+','c-+','r-<','g-<','b-<','k-<','m-<','c-<'};
for i=1:1:size(z1,2)-1
figure(i) % select the i-th figure
for j=1:number_of_lines(i)
plot(xdata(i,j),ydata(i,j),colorlinestyle1{j})
% Plot the j-th line in the i-th plot, using style j
hold on % keep on plotting in figure i
end
hold off % release figure i
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!