I have 3 column data. I plot 2D 3 axis graph in Excel. I want the same also with colours and labels on Matlab. It is attached as graph name. Can you help me please?

 채택된 답변

Star Strider
Star Strider 2020년 2월 14일

1 개 추천

I have no idea which column is which curve.
Try this:
[D,T,R] = xlsread('Kitap3.xlsx');
Q1 = D(1:15,:);
time = linspace(0, size(D,1), size(D,1));
figure
yyaxis left
plot(time, D(:,1))
hold on
plot(time, D(:,2))
yyaxis right
plot(time, D(:,3))
hold off
Experiment with the column assignments to get the result you want.
See the documentation on yyaxis for details.

댓글 수: 6

N/A
N/A 2020년 2월 17일
@star strider thank you for your answer. Code is working very well but I don't want one of line as a dashed line. How can I fix this.
As always, my pleasure!
For yyaxis plots, the only way is to make them differnt colours.
Since I assume you are referring to the yyaxis left plot, try this:
yyaxis left
plot(time, D(:,1) ,'-b')
hold on
plot(time, D(:,2), '-g')
The rest of the code is unchanged.
N/A
N/A 2020년 2월 18일
@star strider. Thank you very much, and this is my last question I promise :) How can I add a label on right yy axis?
As always, my pleasure.
Try this:
figure
yyaxis left
plot(time, D(:,1))
hold on
plot(time, D(:,2))
hold off
ylabel('Left y-Axis')
yyaxis right
plot(time, D(:,3))
ylabel('Right y-Axis')
xlabel('Time')
This labels both of them, and the x-axis. Delete the ones you do not need.
N/A
N/A 2020년 2월 20일
Thank you :)
Star Strider
Star Strider 2020년 2월 20일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

N/A
2020년 2월 14일

댓글:

2020년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by