Как на графике выровнять метки точек и обозначение оси в одну линию?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aleksandr
el 5 de Nov. de 2025
Respondida: Cris LaPierre
el 5 de Nov. de 2025
У меня есть диаграмма.

Есть ли какой-то элегантный способ разместить обозначение оси x в одну линию с метками x1, x2, x3?
На данный момент код для настройки графика у меня выглядит вот так:
xTicks = [pi, 2*pi, 3*pi];
yTicks = [0, 0.5];
ax = gca;
ax.XTick = xTicks;
ax.XTickLabel = {'$x_1$','$x_2$','$x_3$'};
ax.YTick = yTicks;
ax.YTickLabel = {'0','$\lambda_0$'};
ax.FontSize = 14;
ax.TickLabelInterpreter = 'latex';
xlabel('$x$', 'Interpreter', 'latex');
ylabel('$y$', 'Interpreter', 'latex');
ax.XAxis.LabelHorizontalAlignment = 'right';
ax.YAxis.LabelHorizontalAlignment = 'right';
ax.YAxis.Label.Rotation = 0;
ax.LabelFontSizeMultiplier = 1;
1 comentario
Walter Roberson
el 5 de Nov. de 2025
Approxiomate translation:
How to align point labels and axis labels on a chart?
I have a diagram.
Is there an elegant way to align the x-axis label with the x1, x2, and x3 labels?
Currently, my chart setup code looks like this:
Respuesta aceptada
Cris LaPierre
el 5 de Nov. de 2025
Perhaps not the expected solution, but this works: add the xlabel and ylabel as an xtick/ytick label at the axis limit.
x = linspace(0,15,50);
y = -sin(x);
plot(x,y,'.-')
pos = axis;
xticks([pi, 2*pi, 3*pi pos(2)])
xticklabels({'$x_1$','$x_2$','$x_3$','$x$'});
yticks([0, 0.5, pos(4)])
yticklabels({'0','$\lambda_0$','$y$'});
ax = gca;
ax.FontSize = 14;
ax.TickLabelInterpreter = 'latex';
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Axis Labels en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
