Why are tick marks only on one axis when I change the tick spacing?

I am making a plot in MATLAB, and I want to specify the spacing of tick marks and grid lines.
By default, I get something like this:
But I want both the x and y axes to have have lines with a spacing of 1. So I changed the code to this:
axis equal;
xticks(1:1:5);
yticks(1:1:5);
grid on;
However, this causes the graph to look like this:
Notably, the horizontal grid lines and y-axis tick marks and labels are entirely gone. I have no clue why this would be. This seems like something that should be very straightforward, so not sure where the error could be coming in. Any help would be greatly appreciated. Thanks.

 Réponse acceptée

Try
yticks(-4:0)

3 commentaires

Right. The y range is negative, so specifying positive ticks makes all of the ticks be out of the plotting area.
Raven
Raven le 26 Jan 2023
Modifié(e) : Raven le 26 Jan 2023
Welp, that was pretty straightforward. Not sure how I missed that, but thanks.
You are quite welcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2022a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by