Make axis line invisible but not tick labels
조회 수: 82 (최근 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!