Need Help!!!! How Can I Label the y axis on the right side? I did it and it still does not appears on right side of the graph

147 ビュー (過去 30 日間)
Kim Hao Teong
Kim Hao Teong 2017 年 11 月 19 日
回答済み: Hamid Oral 2022 年 1 月 14 日
This is part of the code I have been working on:
if true
% codetitle('Moody Chart')
xlabel('Reynolds number Re')
ylabel('f')
yyaxis right
set(gca,'yscale','log','YTick',[0.00001 0.00002 0.0001 0.0002:0.0002:0.001 0.002:002:0.01 0.015 0.02:0.01:0.05]);
ylabel({'Relative Roughness'; 'e/D'})
grid on
end
It came out like this, there is not y axis labels on the right side
As opposed to this

回答 (2 件)

Hamid Oral
Hamid Oral 2022 年 1 月 14 日
You can see the properties of a plot with the following command:
>get(gca)
...
YAxisLocation: 'left'
...
You will have a list of properties on the screen. You can pick and choose the one you would like to change and do it as follows:
>set(gca,'YAxisLocation','right')
This way you would be placing the Y axis on the right side, while the default is left

Paola Faoro
Paola Faoro 2020 年 12 月 16 日
編集済み: Paola Faoro 2020 年 12 月 16 日
Hi Kim
I can see that both the y axis label ‘Relative Roughness e/D’ and the yticks appear at the right of your plot, so I’m assuming you would like to see the yticklabels on the right as well.
For that you can use the yticks and yticklabels commands as shown below, and adjust the values to match your need.
if true
% codetitle('Moody Chart')
xlabel('Reynolds number Re')
ylabel('f')
yyaxis right
% set(gca,'yscale','log','YTick',[0.00001 0.00002 0.0001 0.0002:0.0002:0.001 0.002:002:0.01 0.015 0.02:0.01:0.05]);
ylabel({'Relative Roughness'; 'e/D'})
yticks([0.1 0.5 1])
yticklabels ({'y=0', 'y=0.5', 'y=1'})
grid on
end
Here are some doc pages that may be useful to refer to:
Best,
Paola

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by