set the Ticks only on the X and Y axis

3 views (last 30 days)
How can I set the Ticks only on the X and Y axis as shown in the following image:

Accepted Answer

Star Strider
Star Strider on 14 Apr 2017
Set the axis box to 'off'.
Example
x = 0:20;
y = sin(x*pi/9);
figure(1)
plot(x, y);
grid
ha = gca;
ha.Box = 'off';
See if that does what you want to do.
See the documentation for Axes Properties (link) for details.
  2 Comments
boureghda mohammed
boureghda mohammed on 15 Apr 2017
Edited: boureghda mohammed on 15 Apr 2017
Star Strider, I want to delete only the Ticks with conserving the line.
Star Strider
Star Strider on 15 Apr 2017
if you want the lines but not the ticks, you have to plot each of them separately as lines:
x = 0:20;
y = sin(x*pi/9);
figure(1)
plot(x, y);
hold on
plot(xlim, [1 1]*max(ylim), '-k') % Top Box Limit Without Ticks
plot([1 1]*max(xlim), ylim, '-k') % Right Box Limit Without Ticks
hold off
grid
hax = gca;
hax.Box = 'off';

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!