How to make axis invisible? But not xlabel and ylabel!

55 ビュー (過去 30 日間)
Mr M.
Mr M. 2017 年 6 月 23 日
編集済み: Thorsten 2018 年 8 月 7 日
I would like to make axis invisible but not the xlabel and ylabel text

回答 (2 件)

Akira Agata
Akira Agata 2017 年 6 月 24 日
How about overwriting a white axis on the original X- and Y-axis, like:
figure
plot(magic(4));
ax1 = gca;
hold on
ax2 = axes('Position',ax1.Position,...
'XColor',[1 1 1],...
'YColor',[1 1 1],...
'Color','none',...
'XTick',[],...
'YTick',[]);
  1 件のコメント
Mr M.
Mr M. 2018 年 7 月 3 日
編集済み: Mr M. 2018 年 7 月 3 日
set(gca,'ycolor','w') makes the ylabel white for me too!

サインインしてコメントする。


Thorsten
Thorsten 2018 年 8 月 7 日
編集済み: Thorsten 2018 年 8 月 7 日
The trick is to create handles to the labels and use these handles to re-set the color of the labels after the color of the axes has been set to white.
plot(rand(1,10))
h(1) = xlabel('x');
h(2) = ylabel('y');
axesoffwithlabels(h)
Using
function axesoffwithlabels(h)
%AXESOFFWITHLABELS Make axes invisible but not the xlabel and ylabel.
%
% AXESOFFWITHLABELS(H) makes axes invisible, keeping the x- and ylabel
% with handle H.
%
% Sample Usage
% plot(rand(1,10))
% h(1) = xlabel('x');
% h(2) = ylabel('x');
% axesoffwithlabels(h)
%
% Thorsten.Hansen@psychol.uni-giessen.de 2018-08-08
set(gca, 'Xcolor', 'w', 'Ycolor', 'w')
set(h, 'Color', 'k')
% get rid of the white ticks and tick labels, moving the labels closer to
% the axes
set(gca, 'XTick', []);
set(gca, 'YTick', []);
end

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by