Plot different color data range
조회 수: 10 (최근 30일)
이전 댓글 표시
Hello everyone,
I want to plot a simple time series over time, but with 2 different colors.
For a specific range of data on my x-axis (time values), I want to change the color.
How can I do that?
Thanks in advance!
댓글 수: 3
답변 (1개)
Sindar
2020년 1월 9일
Based on this answer: https://www.mathworks.com/matlabcentral/answers/1156-conditional-plotting-changing-color-of-line-based-on-value#answer_1661:
x = -10:.01:10;
y = sin(x);
idx = x<=0;
plot(x(idx),y(idx),'r*',x(~idx),y(~idx),'b*')
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!