How do I add color to this line of code without repeating the time variable everytime?
1 次查看(过去 30 天)
显示 更早的评论
plot(time,[accLong,accVert,accLat,],'linewidth',2) % plot all
I do not want to use this version
plot(time,accLong,'r',time,accVert,'b',time,accLat,'k','linewidth',2) % plot all
0 个评论
采纳的回答
Ameer Hamza
2020-9-24
Use plot handles to set the color
t = 1:10;
x1 = rand(size(t));
x2 = rand(size(t));
p = plot(t, [x1; x2]);
p(1).color = 'r'; % color of first line
p(2).color = 'b'; % color of second line
2 个评论
Ameer Hamza
2020-9-24
I don't think there is an easy way. Any other solution will lead to more variables.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!