How to set the y-axis values to be only integers?

85 visualizaciones (últimos 30 días)
gsourop
gsourop el 15 de En. de 2018
Respondida: Thorsten el 15 de En. de 2018
Hi everybody,
If I have the following vector
x = [1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 2 2 3 3 3 3];
and I want to create a plot on which the y-axis will contain integers between 0 and 4 (including 0 and 4), without showing any numbers in between, such as 2.8 or 1.2 for example. Hence, plot(x) doesn't work on that case. Could someone help on this please? Thanks in advance.

Respuesta aceptada

Thorsten
Thorsten el 15 de En. de 2018
plot(x)
a = axis;
axis([a(1) a(2) 0 4]);
set(gca, 'YTick', 0:4)

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by