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!