Borrar filtros
Borrar filtros

How to write x-ticks in latex.

54 visualizaciones (últimos 30 días)
Atom
Atom el 8 de Nov. de 2022
Respondida: Star Strider el 8 de Nov. de 2022
How to write x-ticks in latex.
I tried with
xticklabels({'x_m','x_2'},'interpreter','latex')
But failed. Please suggest or modify the code so that I can get the desired xticklabels $x_m$ and $x_2$ at x=0.2,0.5 respectively in latex.
plot([.2 .2], [0 .35],'--k')
hold on
plot([.5 .5], [0 .35],'--k')
axis([0 1 0 .35]);
xticks([.2 .5])
xticklabels({'xm','x2'})
xlabel('$x\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
ylabel('$y\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

Respuesta aceptada

Star Strider
Star Strider el 8 de Nov. de 2022
Try this —
plot([.2 .2], [0 .35],'--k')
hold on
plot([.5 .5], [0 .35],'--k')
axis([0 1 0 .35]);
xticks([.2 .5])
Ax = gca;
Ax.XAxis.TickLabels = {'$x_m$','$x_2$'}; % Changed
Ax.XAxis.TickLabelInterpreter = 'latex'; % Added
xlabel('$x\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
ylabel('$y\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by