Make axis line invisible but not tick labels
49 views (last 30 days)
Show older comments
I want to the make the X and Y axes invisible (not white), so I have used different ways:
set(gca,'xcolor','none') or gca.XAxis.Visible = 'off';
In both cases the axes disappear but so do the tick labels, which I want to keep. I've tried the following but to no avail:
gca.XAxis.Label.Color = [0 0 0]; gca.XAxis.Label.Visible = 'on'
0 Comments
Answers (2)
Srivardhan Gadila
on 30 May 2020
Edited: Srivardhan Gadila
on 11 Jun 2020
As per my knowledge w.r.t current documentation, I think there is no way to make borders dissapear along all the sides with tick labels to remain appeared.
The propety Box removes the box outline but only on the right and top sides of the box, so no use of using it.
Setting the ax.XAxis.Visible = 'off'; also makes the TickLabels invisible, so no use of this too.
If it helps, you can pass the Tick Labels together as one string to ax.XAxis.Label.String then set the ax.XAxis.Visible = 'off' & ax.XAxis.Label.Visible = 'on'. Do the siimilar thing w.r.t YAxis.
0 Comments
Marta Jimenez
on 14 Aug 2020
I managed to solve a similar problem ... in case it can help someone.
First I created my plot, and when everything was there (labels, title, yticklabels...), I superimposed another axes.
hold on
b=barh(MyTable.Order,MyTable.NrElements,'FaceColor',BarsColor);
ax1=gca;
%...Rest of code:
%In my case I did not want the XTicks or labels either, but if you comment this part
% they will appear
set(ax1, 'XTick', []);
set(ax1,'TickLength',[0 0])
%Get rid of X axis overlapping a white one over
% In my case I wanted to keep the y axis, so I overwrited with black [0 0 0] but
% if you set it to [1 1 1] it will disappear too
ax2 = axes('Position',ax1.Position,...
'XColor',[1 1 1],...
'YColor',[0 0 0],...
'Color','none',...
'XTick',[],...
'YTick',[]);
hold off
0 Comments
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!