Is it possible to use yticks only on one side?

68 views (last 30 days)
Is it possible to use yticks only on one side? How to set?
Adam on 5 Oct 2018
I can't actually see any way to turn them off using sensible functionality. For the y ticks specifically you can use an ugly hack e.g.:
figure; imagesc( magic(25) )
yyaxis right
set( gca, 'YTick', [] )
set( gca, 'YColor', 'k' )
though I don't know a way to do it for the x axis and the above is horrible code. yyaxis is an ugly function since it gives no possibility to actually return the axis handle and instead just changes what is the current axes.

Sign in to comment.

Accepted Answer

jonas on 5 Oct 2018
Edited: jonas on 5 Oct 2018
The yticks appear on both sides due to the box being 'on', so to say. Remove them by
box off
This will of course also remove the frame, so here is a bonus hacky solution for retaining the frame
box off
jonas on 5 Oct 2018
Seems like this should be an option for 'boxstyle', but currently there is only one option for 2D plots. In this specific case I think the extra axes is OK, because it is just an empty frame. You can still zoom if you have the primary axes as the current axes. You'd need to set the background transparent though
so that the second axes is visible below the primary.

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!