How to get the x axis and y axis to start at 0 when adding regression line in Figure window

8 visualizaciones (últimos 30 días)
How do I edit the graph to get the x and y axis at 0 to line up at 0 instead of the way it is spaced?

Respuesta aceptada

Scott MacKenzie
Scott MacKenzie el 14 de Mayo de 2021
I'm assuming you don't want to loose the points with y < 0. Something like this should work...
% test data
x = 1:100;
y = linspace(1,60) + randi([-5 5], 1, 100);
p = scatter(x, y, 'filled');
lsline;
ax = gca;
ax.YLim = [-10 70];
ax.XAxisLocation = 'origin';
  3 comentarios
Scott MacKenzie
Scott MacKenzie el 14 de Mayo de 2021
In that case, look for the XAxisLocation property in the Property Inspector and set it to "origin".

Iniciar sesión para comentar.

Más respuestas (1)

David Fletcher
David Fletcher el 14 de Mayo de 2021
Editada: David Fletcher el 14 de Mayo de 2021
Does the axis command do anything:
axis([0 70 0 70])
  1 comentario
Stephnie Watson
Stephnie Watson el 14 de Mayo de 2021
Editada: Stephnie Watson el 14 de Mayo de 2021
How would I add the axis code in the Figure window? I don't have any code that I have created. I used create plot then opened the Figures window to add the regression line.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by