MATLAB Answers

controlling ylable tick of a figure

4 views (last 30 days)
Niki
Niki on 8 Mar 2014
Commented: Niki on 9 Mar 2014
Hi,
M y label tick is like
2 2.2 2.4 2.8 3 3.2 3.4 3.6
I want not to show the labels of 2 ,2.2 and 2.4 but in my figure show the rest. does anyone know how to do it ? I found a way to do it manually but I want to know how to do it in another way

  0 Comments

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 8 Mar 2014
Edited: the cyclist on 8 Mar 2014
This sounds like it does what you want. It is also fairly "manual", but what you want is pretty specific, so maybe that can't be avoided.
If you have a more general rule, like "I only want ticks greater than 3", then that could be put to use. However, you don't give enough detail to guess what you want.
y = [2 2.2 2.4 2.8 3 3.2 3.4 3.6];
x = y./2;
figure
plot(x,y,'.-')
set(gca,'YTick',[2.8:0.2:3.6],'YTickLabel',[2.8:0.2:3.6])

  3 Comments

Niki
Niki on 8 Mar 2014
I only want to show the Ytick for specific label and only specific labels of Y-axis. but thanks, what you showed works just fine. May you please tell me how to also remove the tick of (title) and right side of a figure?
Azzi Abdelmalek
Azzi Abdelmalek on 8 Mar 2014
Why not just
set(gca,'YTick',[2.8:0.2:3.6])
Niki
Niki on 9 Mar 2014
you are right azzi , this works

Sign in to comment.

More Answers (0)

Tags


Translated by