MATLAB: Boxplot: second Y axes labels

axesboxplotlabels

How can i put the same labels also on both left and right Y axes (tried several solutions but can't make them work as I wish)?
boxplot(rand(100,10))
Thanks
Oleg

Best Answer

I can only think of a workaround...
EDIT: Per Oleg's comment, I've added a "ResizeFcn" for the figure to adjust the axes properties when the figure is resized.
EDIT 2: Added zoom post action so that the tick labels update upon zoom as well.
function boxplot_test
boxplot(rand(100,10));
ax1 = gca;
ax2 = axes('Position', get(ax1, 'Position'), ...
'Color', 'none', 'YAxisLocation', 'right', ...
'XTick', [], 'YTick', get(ax1, 'YTick'), ...
'YLim', ylim(ax1), 'HandleVisibility', 'off');
uistack(ax1);
set(gcf, 'ResizeFcn', @resize);
h = zoom(gcf); % <-- EDIT 2

set(h, 'ActionPostCallback', @resize); % <-- EDIT 2
function resize(varargin)
set(ax2, 'Position', get(ax1, 'Position'), ...
'YTick', get(ax1, 'YTick'), ...
'YLim', ylim(ax1));
end
end