Alternating color code in a dotted Circle
1 view (last 30 days)
Show older comments
Sonia-Frida Ndifon
on 19 Mar 2021
Commented: Sonia-Frida Ndifon
on 19 Mar 2021
I have plotted a circle with red dots using the sine and cosine functions , but I am trying to edit it such that every other dot color is blue. Here is my code
t=0:0.1:2*pi;
figure
hold on
for i=1:numel(t)
sine=sin(t);
cosine=cos(t);
end
plot(sine,cosine,'r.')
xlim([-1.25 1.25])
ylim([-1 1])
axis equal
0 Comments
Accepted Answer
Cris LaPierre
on 19 Mar 2021
All markers in a series will have the same color, so the best approach I can think of is to plot two separate series, one with red markers and the other with blue.
t=0:0.1:2*pi;
figure
sine=sin(t);
cosine=cos(t);
plot(sine(1:2:end),cosine(1:2:end),'r.')
hold on
plot(sine(2:2:end),cosine(2:2:end),'b.')
hold off
xlim([-1.25 1.25])
ylim([-1 1])
axis equal
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!