Create a plot with 2 left axes and 1 right axis

42 ビュー (過去 30 日間)
Heidi Hirsh
Heidi Hirsh 2019 年 7 月 21 日
回答済み: DGM 2021 年 12 月 24 日
Hi!
I want to plot three datasets on top of each other (same plot not subplots). Each has its own units so I want to have two different axes/scales on the left side and one on the right. I know how to plot double axes with yyaxis left and yyaxis right. Can I do two yyaxis left lines or something?

回答 (2 件)

Sai Sri Pathuri
Sai Sri Pathuri 2019 年 7 月 24 日
To plot three datasets on top of each other, set hold command to ON after creating axes object.
axes;
hold on;
The axes command creates an axes object with y-axis on the left by default. Then a yyaxis left and yyaxis right can be used to create another y-axis on left and a y-axis on right respectively.
For more information, refer the following link for documentation:
  1 件のコメント
F S
F S 2021 年 12 月 24 日
Your link only shows how to create a plot with two yaxis, one on the left and one on the right respectively. So does your example. The question asked how to create a plot with three yaxis in the same axes.
Is there a way to plot three yaxis into the same axis, e.g. with ticks going in and out on the side with two yaxis?

サインインしてコメントする。


DGM
DGM 2021 年 12 月 24 日
I don't know how it would be done with yyaxis (if possible)
There are a number of old tools on the File Exchange that still work.
https://www.mathworks.com/matlabcentral/fileexchange/9016-addaxis (aa_splot.m needs edited; see FEX comments)
and you can search for others.
x = 1:10;
y1 = x;
y2 = x*10 + 2*rand(1,10);
y3 = x/10 + rand(1,10);
% using plotyyy()
plotyyy(x,y1,x,y2,x,y3,{'this one','that one','the other one'});
% using addaxis()
figure
plot(x,y1);
addaxis(x,y2);
addaxis(x,y3);
addaxislabel(1,'this one');
addaxislabel(2,'that one');
addaxislabel(3,'the other one');

カテゴリ

Help Center および File Exchange2-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