필터 지우기
필터 지우기

Plot 2 sets of data in different colour

조회 수: 4 (최근 30일)
Auryn_
Auryn_ 2017년 2월 16일
댓글: Auryn_ 2017년 2월 16일
Hi,
I am trying to plot a set of data but in fact is formed by 2 different set of data, the second starting where the first one ends. In order to understand what I mean, imagine I have: a=linspace(1,10); b=linspace(10,20); then I will have something like: c=[a b]; which will give me a line with all the values. Can I make the same line in 2 different colours, I mean, can make c with a colour representing the data in a and another colour for the data in b? Thanks in advance!

답변 (1개)

KSSV
KSSV 2017년 2월 16일
figure
plot(rand(10,1),rand(10,1),'r',rand(20,1),rand(20,1),'b')
% or
figure
plot(rand(10,1),rand(10,1),'r')
hold on
plot(rand(20,1),rand(20,1),'b')
  댓글 수: 6
Adam
Adam 2017년 2월 16일
A single line object cannot have multiple colours, but does it matter how many line objects you have?
Auryn_
Auryn_ 2017년 2월 16일
I have done it at the end with multiple plots. Thanks anyway!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by