How to set a general ylabel in the right side of a figure composed of various tiles?

77 ビュー (過去 30 日間)
Gerardo Carrillo
Gerardo Carrillo 2021 年 1 月 27 日
コメント済み: Ruslan 2021 年 8 月 27 日
I have a figure that is composed of two tiles. After plotting I want to set a general ylabel in the left and a general ylabel in the right, but I cannot find how to do it for the right side. The code is something like this:
t=tiledlayout('flow');
nexttile
yyaxis left
%plot something
yyaxis right
%plot something
nexttile
yyaxis left
%plot something
yyaxis right
%plot something
xlabel(t, 'p_2 (percentage)')
ylabel(t, 'Mean travel time (seconds)')
%Now, how to put the general ylabel for the right side?
  2 件のコメント
VBBV
VBBV 2021 年 1 月 28 日
編集済み: VBBV 2021 年 1 月 28 日
Assign the handles to yhe plot and use it in xlabel and ylabel like you did
Ruslan
Ruslan 2021 年 8 月 27 日
Did you find any solution?

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

回答 (1 件)

Shubham Rawat
Shubham Rawat 2021 年 2 月 4 日
Hi Gerardo,
You may use this code snippet to label Xlabel with left label and right label at a time:
for i=1:2
set( get(subplot(2,1,i),'XLabel'), 'String', 'This is the X label' );
yyaxis left
set( get(subplot(2,1,i),'YLabel'), 'String', 'left Y label' );
yyaxis right
set( get(subplot(2,1,i),'YLabel'), 'String', 'right Y label' );
end
You may refer to this link for more information:
Hope this Helps!

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by