Reputation: 341
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?
Upvotes: 8
Views: 26069
Reputation: 1
Probably not relevant to the old versions, but here is how I did mine.
plot(X,Y)
ylabel('Intensity [a.u.]'); %creates y axis label named 'Intensity [a.u.]'
yticklabels(' '); %sets tick labels to ' ' (space)
This might be what is shown in other explanations, but those made no sense to me. I am using version 2021a.
Upvotes: 0
Reputation: 51
Try:
ax1 = gca; % gca = get current axis
ax1.YAxis.Visible = 'off'; % remove y-axis
ax1.XAxis.Visible = 'off'; % remove x-axis
Upvotes: 5
Reputation: 744
I know this is an old post, but the following also remove the tick marks which is probably what you want:
set(gca, 'YTick', []);
Upvotes: 6
Reputation: 155
To remove labels from a plot, use the following commands for X-axis or Y-axis:
set(gca,'XTickLabel',{' '})
set(gca,'YTickLabel',{' '})
Upvotes: 2
Reputation: 1193
Before exporting the figure, do
set(gcf, 'InvertHardCopy', 'off');
Upvotes: 2
Reputation: 3249
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!
Upvotes: 0