필터 지우기
필터 지우기

How to make line plot of 3 different colors?

조회 수: 1 (최근 30일)
Zhou Ci
Zhou Ci 2021년 7월 25일
편집: Zhou Ci 2021년 7월 25일
Hello everyone,
Is there a way to change colors of line plot different at specific intervals? For example, I want line from 18-0 to be of one color, from 0-(-10) represents different color and -10 till -35 to be of an other color. Thank you.

채택된 답변

Chunru
Chunru 2021년 7월 25일
% data
x = [2:26 26:-1:-5];
y = [20:-1:-4 -5:-1:-36];
idx1 = y>=0;
idx2 = y>=-10 & y<=0;
idx3 = y<=-10;
plot(x(idx1), y(idx1), 'r-', x(idx2), y(idx2), 'g-', x(idx3), y(idx3), 'b-');
set(gca, 'YDir', 'reverse')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Instrument Connection and Communication에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by