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

154 visualizzazioni (ultimi 30 giorni)
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

Risposte (2)

Hamid Oral
Hamid Oral il 14 Gen 2022
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 il 16 Dic 2020
Modificato: Paola Faoro il 16 Dic 2020
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

Categorie

Scopri di più su Graphics in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by