How can I set two different color for each lsline in the scatter plot?
Show older comments
Hello,
I have one question about lsline.
Basically, I want to have two lsline(C and D), one for A and one for B respectively.
I would like to set different color for each lsline and also would like to make legend for each one.
So I wrote the code as below. However, it gives me the two blue lsline instead of one read and one blue.
So I was wondering how should I make the code to get the right figure.
Thanks in advance.

% Subplot
figure(6)
A = scatter(semi2008(h_to_plot),semi2001(h_to_plot),[],[0 0.4470 0.7410],'o','Linewidth',1);
hold on
C = lsline;
hold on
B = scatter(semi2008_zoomed(h_to_plot_zoomed),semi2001(h_to_plot_zoomed),[],[0.8500 0.3250 0.0980],'o','Linewidth',1);
hold on
D = lsline;
hold on
grid on
xlabel('2008')
ylabel('2001')
legend([A B C D],'scatter1','scatter2','line1','line2','Location','southeast')
set(C,'color','r')
set(D,'color','b')
Accepted Answer
More Answers (0)
Categories
Find more on Scatter 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!