The function PLOTYY creates two sets of axes and uses the property YAxisLocation to put them on different sides on a figure. By default, Y tick marks are spaced such that the overlap exactly and it appears that there is only one set of tick marks on each of the Y axes.
However, when tick mark properties (such as their quantity, spacing or Y limits) are modified manually, without ensuring that the same number of tick marks is present on both axes, the above behavior is seen (i.e. two sets of tick marks on one of the axes).
The axis property 'Box' controls the presence of Tick marks on both sides on an axis. By default, PLOTYY sets the value of this property to 'off' for the right axes and to 'on' for the left axes (that is why the double tick marks appear on the right axes).Setting the value of the property 'box' to 'off' for both axes will remove the extra sets of tick marks from the other side as well.
However, this will also remove the top edge of the axes (the bounding box) and the image may look borderless when it is saved or printed. As a workaround, one of the two sets of X axes (which were created with PLOTYY) may be moved to the top of the figure, effectively replacing the bounding box along that edge. The two X axes may need to be linked via the command LINKAXES to make sure that the two plots are synchronized when zooming in.
The following code illustrates the issue and the workaround, step by step (note the commands PAUSE in this code):
t = 1:100;
y1 = abs(1e4*sin(.01*t));
y2 = abs(cos(.02*t));
fg = figure(5);
[AX,H1,H2] = plotyy(t, y1, t, y2);
Nticks = 8;
y1 = linspace(0, 8e4, Nticks);
y2 = linspace(0, 14, Nticks+4);
set(AX(1), 'ylim', [y1(1), y1(end)], 'ytick', y1);
set(AX(2), 'ylim', [y2(1), y2(end)], 'ytick', y2);