hey i was wondering if somebody knows how to make a 2D plot with 3 axis...with that i mean a normal 2D plot that has two y axis (i.e. the left and right y axis have different scales) and one x-axis?
thanks for youre help
david

답변 (3개)

Wayne King
Wayne King 2012년 5월 13일

3 개 추천

Have you seen plotyy?
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
david scholz
david scholz 2012년 5월 13일

0 개 추천

hey wayne
no i hadnt, thanks alot!
ds
Ferran Guedea I Ripoll
Ferran Guedea I Ripoll 2015년 4월 24일

0 개 추천

I have created a 2D plot with 3 axis thanks to the plotyy command. Now I want to reformat all 3 axis: max, min limits and ticks for the axis. For the x axis and y principal axis I have been able with the basic commands but not for the 2nd Y axis. Any idea? Thank you in advance -Ferran

댓글 수: 3

When you call the plotyy function, you can include output arguments. From the answer above:
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot'); %include output arguments
You can use these handles to change the properties of the plot eg:
%sets Y limits for axis 1 (left axis) to -300 and 400
%and automatically spaces ticks
set(AX(1),'YLim',[-300 400],'YTickMode','auto')
%sets Y limits for axis 1 (left axis) to -300 and 400
%and automatically spaces ticks
set(AX(2),'YLim',[-1 1],'YTickMode','auto')
There are many different features you can change for the two axes (AX) and the two plots (H1 & H2). The full list of options can be seen using:
%get list of features for AX(1) - left axis
get(AX(1))
Devaprasad M
Devaprasad M 2020년 12월 17일
How to add label for third axis in Plotyy
Ahmad Khalid
Ahmad Khalid 2020년 12월 19일
yyaxis right;
ylabel ('axis-3 label')

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

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

질문:

2012년 5월 13일

댓글:

2020년 12월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by