Plotting leaving empty space before line begins

9 visualizaciones (últimos 30 días)
Ian Bunker
Ian Bunker el 13 de Mayo de 2021
Editada: Cris LaPierre el 13 de Mayo de 2021
So this plot has a gap before the beginning of the line. I have checked the arrays being inputted and they have the correct values and therefore there should be no gap.
My current theory is based on the bottom and that when the program plots the points it is rounding the axis numbers and therefore not centering the graph at the start of the line.
Any ideas on how to fix this?

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 13 de Mayo de 2021
Editada: Cris LaPierre el 13 de Mayo de 2021
Yes, by default MATLAB will attempt to set the ticks at round numbers. If you prefer to have the limits exactly match your data, use axis tight
x = rand(1,5);
y = rand(1,5);
tiledlayout(1,2)
nexttile
plot(x,y)
title('Normal')
nexttile
plot(x,y)
title('axis tight')
axis tight
  1 comentario
Ian Bunker
Ian Bunker el 13 de Mayo de 2021
Thanks! I am just glad that it is not a problem with my arrays but something that matlab does automatically.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D 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