How to plot two lines with different scales in MATLAB?

조회 수: 12 (최근 30일)
Armando MAROZZI
Armando MAROZZI 2020년 12월 6일
댓글: Armando MAROZZI 2020년 12월 6일
I have attached the dataset I have
y = readtable('t.csv');
The dataset has 4 columns: ignoring the first one, the second one indicates "Date" and the other two columns, respectively, data1 and data2 with different scales.
I want to plot the two series in one graphs but on the y-axes the different scales. Besides, on the x.axis I would like to display "Date". However, the series is not regularly monthly. I don't know how to take care of it as well.
I have been trying with "yyaxis" but I got nothing out of it.
Can anyone help me?
Thanks a lot!

채택된 답변

dpb
dpb 2020년 12월 6일
So what, specifically did you try and what didn't work? Seems straightforward...
t=readtable('t.csv');
plot(t.Date,t.IP)
ylabel('IP')
yyaxis right
plot(t.Date,t.Sentiment)
ylabel('Sentiment')
xlabel('Date')
I can guess 'Sentiment', what is IP?
  댓글 수: 1
Armando MAROZZI
Armando MAROZZI 2020년 12월 6일
Thanks a lot! I made a very silly mistake in selecting the right columns! thanks again

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by