Make axis line invisible but not tick labels
70 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Srivardhan Gadila
2020 年 5 月 30 日
編集済み: Srivardhan Gadila
2020 年 6 月 11 日
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 件のコメント
Marta Jimenez
2020 年 8 月 14 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Axis Labels についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!