Effacer les filtres
Effacer les filtres

how to edit x axis and y axis values?

1 vue (au cours des 30 derniers jours)
Kaluachchi Gedara Saumya Bandara
Commenté : Star Strider le 30 Nov 2021
How to edit these numerical values in the form of variables? for a exapme x1, x2 ......... on the graph

Réponse acceptée

Star Strider
Star Strider le 30 Nov 2021
Use the Axis Properties, specifically XTickLabel, YTickLabel, and ZTickLabel to specify them.
x = 1:10;
y = rand(size(x));
figure
plot(x, y)
Ax = gca;
xt = Ax.XTick;
Ax.XTickLabel = compose('x%d',(1:numel(xt))); % As Numbers
yt = Ax.YTick;
Ax.YTickLabel = compose('y_{%d}',(1:numel(yt))); % As Subscripts
Another option is the NumericRuler Properties property TickLabelFormat, however I believe the Axis Properties functions are more appropriate here.
Experiment to get different results.
.
  2 commentaires
Kaluachchi Gedara Saumya Bandara
could you please tell me how to edit the points that only intersect x axis and y axis?
Star Strider
Star Strider le 30 Nov 2021
I will do my best, however I have no idea what the desired result is.
One option is to use a legend object to identify the lines, the other is to use text objects for each point of interest.
x = 1:10;
y = rand(size(x));
figure
plot(x, y)
Ax = gca;
xt = Ax.XTick;
Ax.XTickLabel = compose('x%d',(1:numel(xt))); % As Numbers
yt = Ax.YTick;
Ax.YTickLabel = compose('y_{%d}',(1:numel(yt))); % As Subscripts
text(x(1), y(1), sprintf('$$\\ \\leftarrow x=%.2f,\\ y=%.2f$$',x(1),y(1)), 'Horiz','left', 'Vert','middle', 'Interpreter','latex')
text(x(end), y(end), sprintf('$$x=%.2f,\\ y=%.2f\\ \\rightarrow$$',x(end),y(end)), 'Horiz','right', 'Vert','middle', 'Interpreter','latex')
Make appropriate changes to get the desired result.
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by