Filter löschen
Filter löschen

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

40 Ansichten (letzte 30 Tage)
Mr M.
Mr M. am 23 Jun. 2017
Bearbeitet: Thorsten am 7 Aug. 2018
I would like to make axis invisible but not the xlabel and ylabel text

Antworten (2)

Akira Agata
Akira Agata am 24 Jun. 2017
How about overwriting a white axis on the original X- and Y-axis, like:
ax1 = gca;
hold on
ax2 = axes('Position',ax1.Position,...
'XColor',[1 1 1],...
'YColor',[1 1 1],...
  1 Kommentar
Mr M.
Mr M. am 3 Jul. 2018
Bearbeitet: Mr M. am 3 Jul. 2018
set(gca,'ycolor','w') makes the ylabel white for me too!

Melden Sie sich an, um zu kommentieren.

Thorsten am 7 Aug. 2018
Bearbeitet: Thorsten am 7 Aug. 2018
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.
h(1) = xlabel('x');
h(2) = ylabel('y');
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)
% 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', []);


Community Treasure Hunt

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

Start Hunting!

Translated by