I would like to have sigma and epsilon in greek symbols in y and x axis respectively (with latex interpreter)

11 vues (au cours des 30 derniers jours)
I would like to have sigma and epsilon in greek symbols in y and x axis respectively (with latex interpreter).
I have the following code, but it does not work as I wish:
T1 = readtable('PVC_Dogbones_media.xlsx', 'VariableNamingRule','preserve')
figure
plot(T1.('epsilon'), T1.('sigma'), '-k', 'LineWidth',0.5)
grid
xlim([0 0.5])
ylim([0 50])
ylabelname = sprintf('$${\tau}$$ [Pa]','${D_{i}}$' );
ylabel(ylabelname, 'fontsize', 11, 'interpreter', 'latex')
set(gca,'xticklabel',num2str(get(gca,'xtick')','%.2f'))
L=legend('PVC','Location','best');
set(L,'Interpreter','latex')
set(gca,'TickLabelInterpreter','latex')
xlabel(sprintf('$$\epsilon$$ [mm]','${D_{i}}$'), 'Interpreter','latex')
ylabel(sprintf('$${\tau}$$ [Pa]','${D_{i}}$'), 'Interpreter','latex')

Réponse acceptée

Yazan
Yazan le 1 Août 2021
Modifié(e) : Yazan le 1 Août 2021
What are you trying to achieve with the sprintf function?? Use the following to name the X- and Y-axis:
x = randn(1, 128);
plot(x)
xlabel('$\epsilon$ [-]', 'interpreter', 'latex');
ylabel('$\sigma$ [MPa]', 'interpreter', 'latex')
  1 commentaire
Francesco Marchione
Francesco Marchione le 1 Août 2021
Yes, but for the y-axis it still does not work:
T1 = readtable('PVC_Dogbones_media.xlsx', 'VariableNamingRule','preserve')
figure
plot(T1.('epsilon'), T1.('sigma'), '-k', 'LineWidth',1.1)
grid
xlim([0 0.5])
ylim([0 50])
xlabel('$\epsilon$ [-]', 'Interpreter','latex');
ylabel('$\sigma$ [MPa]', 'Interpreter','latex');
ylabel(ylabelname, 'fontsize', 11)
set(gca,'xticklabel',num2str(get(gca,'xtick')','%.2f'))
L=legend('PVC','Location','best');
set(L,'Interpreter','latex')
set(gca,'TickLabelInterpreter','latex')

Connectez-vous pour commenter.

Plus de réponses (3)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 1 Août 2021
xlabel('$\epsilon$', 'interpreter', 'latex'); ylabel('$\tau$', 'interpreter', 'latex')
  1 commentaire
Francesco Marchione
Francesco Marchione le 1 Août 2021
Thank you. I have modified my code in this way:
T1 = readtable('PVC_Dogbones_media.xlsx', 'VariableNamingRule','preserve')
figure
plot(T1.('epsilon'), T1.('sigma'), '-k', 'LineWidth',1.1)
grid
xlim([0 0.5])
ylim([0 50])
xlabel('$\epsilon$ [-]', 'interpreter', 'latex');
ylabel('$\sigma$ [MPa]', 'interpreter', 'latex')
ylabel(ylabelname, 'fontsize', 11)
set(gca,'xticklabel',num2str(get(gca,'xtick')','%.2f'))
L=legend('PVC','Location','best');
set(L,'Interpreter','latex')
set(gca,'TickLabelInterpreter','latex')
but the y axis is not properly configured:

Connectez-vous pour commenter.


Sulaymon Eshkabilov
Sulaymon Eshkabilov le 1 Août 2021
xlabel('\epsilon, [-]'); ylabel('\tau, [MPa]')

Francesco Marchione
Francesco Marchione le 1 Août 2021
This line prevented the correct labeling of the y axis
ylabel(ylabelname, 'fontsize', 11)

Catégories

En savoir plus sur Formatting and Annotation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by