8

I plot a horizontal boxplot in MATLAB -- boxplot(y, group,'orientation','horizontal'), and then hide the y-axis using set(gca,'box','off','ycolor','w').

It looks fine on the screen - only the bottom x-axis is visible. But whenever I save the figure to file, using either the print() function or matlabfrag.m, the left y-axis reappears in the output file (although it doesn't show up in MATLAB's visualization of the figure).

How can I keep this y-axis hidden?

Sardar Usama
  • 18,585
  • 9
  • 33
  • 54
Rory
  • 341
  • 1
  • 5
  • 14

5 Answers5

6

I know this is an old post, but the following also remove the tick marks which is probably what you want:

set(gca, 'YTick', []);
CharlieB
  • 626
  • 6
  • 14
5

Try:

ax1 = gca;                   % gca = get current axis
ax1.YAxis.Visible = 'off';   % remove y-axis
ax1.XAxis.Visible = 'off';   % remove x-axis
user8260285
  • 51
  • 1
  • 3
2

Before exporting the figure, do

set(gcf, 'InvertHardCopy', 'off');
Matt Mizumi
  • 1,183
  • 1
  • 11
  • 26
2

To remove labels from a plot, use the following commands for X-axis or Y-axis:

set(gca,'XTickLabel',{' '})
set(gca,'YTickLabel',{' '})
Peter O.
  • 28,965
  • 14
  • 72
  • 87
Amir
  • 155
  • 1
  • 7
0

Something similar happened to me sometime ago with another property. The only way to keep the property was saving directly from the figure menu! I know that it is boring, but helped me!

DanielTheRocketMan
  • 2,812
  • 4
  • 29
  • 51