two stacked y labels on one single y axis
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lloyd Sullivan
le 27 Juil 2018
Commenté : Star Strider
le 27 Juil 2018
Hi,
I am trying to recreate the above graph. However, I cannot get the two ylabels in the correct places. I'd rather not do it manually using the figure editor, but if there is no other option, then i will.
figure
xlim([80 140])
ylim([-0.1 1.4])
ylabel('$\displaystyle\frac{f_v}{f_n}$','interpreter','latex')
% This is the second y label
% ylabel('$\displaystyle\frac{Y}{D}$','interpreter','latex')
xlabel('\it{Re}','interpreter','latex')
ylh = get(gca,'ylabel');
ylp = get(ylh, 'Position');
set(ylh, 'Rotation',0, 'Position',ylp, 'VerticalAlignment','middle',...
'HorizontalAlignment','right')
Any help would be greatly appreciated.
Best regards,
Lloyd
0 commentaires
Réponse acceptée
Star Strider
le 27 Juil 2018
Modifié(e) : Star Strider
le 27 Juil 2018
Insert some empty values between the two LaTeX strings to create spaces (this works with cell arrays):
ytxt = {'$\displaystyle\frac{f_v}{f_n}$';[];[];[];[];[];[];[];[];[];[];'$\displaystyle\frac{Y}{D}$'};
ylabel(ytxt,'interpreter','latex')
Experiment to get the result you want.
EDIT — A somewhat more efficient version that produces the same result (in R2018a):
ytxt = {'$\displaystyle\frac{f_v}{f_n}$';char(repmat(' ',10,1));'$\displaystyle\frac{Y}{D}$'};
Vary the number of spaces (here 10) in the repmat call to produce the result you want. It must always be a column vector.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!