Putting measurement unit and origin in plot

On the mesh grid, I would like on the x-axis in the far right end below the last value to put x1 and also the measurement unit, in my case, cm/s. And at the point (0,0) to write (0,0). Is it possible?
Thank you in advance.

 Respuesta aceptada

Star Strider
Star Strider el 25 de Sept. de 2022

0 votos

I am not exactly certain what you want, however the xlim and text functions would likely be appropriate.

4 comentarios

Alexandra Roxana
Alexandra Roxana el 25 de Sept. de 2022
I would like something like this: https://en.wikipedia.org/wiki/Cartesian_coordinate_system#/media/File:Cartesian-coordinate-system.svg and below x the measurement unit.
That would be relatively straightforward. See the documentation sections on Axes Properties and NumericRuler Properties for details.
Example —
x_grn = 2;
y_grn = 3;
figure
plot([0 x_grn], [1 1]*y_grn, '--g') % Horizontal Green Dashed Line
hold on
plot([1 1]*x_grn, [0 y_grn], '--g') % Vertical Green Dashed Line
scatter(x_grn,y_grn,[],'g','o','filled') % Green Lines Intersection Point
scatter(0,0,'o','filled') % Origin Point
hold off
grid
text(0, 0, '(0,0)', 'Color','m', 'Horiz','left', 'Vert','bottom')
text(x_grn,y_grn,sprintf('(%.0f,%.0f)',x_grn,y_grn), 'Color','g', 'Horiz','left', 'Vert','bottom')
axis([-4 4 -4 4]) % Axis Limits
Ax = gca;
xl = xlim;
Ax.XTick = min(xl) : max(xl); % Tick Values
yl = ylim;
Ax.YTick = min(yl) : max(yl); % Tick Values
Ax.XAxisLocation = 'origin';
Ax.YAxisLocation = 'origin';
axis('square')
This should get you started. I leave the rest to you.
.
Alexandra Roxana
Alexandra Roxana el 26 de Sept. de 2022
Thank you very much!
Star Strider
Star Strider el 26 de Sept. de 2022
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2017a

Preguntada:

el 25 de Sept. de 2022

Comentada:

el 26 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by