How to make axis line invisible but keep xlabel and ylabel?
42 views (last 30 days)
Show older comments
I tried axis off, or set(gca,'xcolor','w'), but the problem is I want to keep the xlabel, morover white color is not good for me, because I am using imagesc and white ticks are visible on the colored figure.
0 Comments
Accepted Answer
jonas
on 23 Jul 2018
Edited: jonas
on 23 Jul 2018
h=get(gca);
set(h,'xcolor','none')
h.XAxis.Label.Color=[0 0 0];
h.XAxis.Label.Visible='on';
6 Comments
Walter Roberson
on 12 Mar 2021
imagesc(rand(32,40))
xlabel('x')
ylabel('y')
zlabel('z')
h = gca; %fixed relative to jonas's suggestion
set(h,'xcolor','none')
h.XAxis.Label.Color=[0 0 0]; h.XAxis.Label.Visible='on';
The y label ticks are visible; the x label ticks are not; the x label itself is visible.
However, I have not tried this in R2019b.
Adam Danz
on 19 Apr 2021
Another approach:
ax.XRuler.Axle.Visible = 'off'; % ax is axis handle
ax.YRuler.Axle.Visible = 'off';
Credit: Yair's UndocumentedMatlab
More Answers (0)
See Also
Categories
Find more on Graphics Objects 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!