Question on plots i,e different line properties

3 views (last 30 days)
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

Answers (2)

Honglei Chen
Honglei Chen on 31 Oct 2012
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.

Jonathan Epperl
Jonathan Epperl on 31 Oct 2012
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

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!