1

I am trying to use MATLABs plotyy function in combination with y-axes limits like that

x = [4:2:14 18];
y1 = [86; 87; 88; 89; 89.3; 89.6; 89.7];
y2 = [15; 35; 63; 99; 143; 195; 323];
width = .36;
axes = plotyy(x-width, y1, x+width, y2, @(x,y) bar(x,y,width,'b'), @(x,y) bar(x,y,width,'r'));
set(axes(1), 'ylim', [85 90]);
set(axes(1), 'ytick', 85:90);
set(axes(2), 'ytick', 0:50:400);
set(axes,'xtick',x)

and this is the result:

The plotyy result with wrong ticks

What I want to get rid of are the ticks on the 2nd y-axis which don't have a tick label. They seem to be leftovers from the 1st y-axis. How can I remove them or avoid them to be drawn?

Rob
  • 919
  • 7
  • 16

2 Answers2

1

Based on the code example in this question, what you should do is:

set(axes(1),'Box','off');

However, this also removes the top line. If you need to keep the line, see the answer to that question as well.

Community
  • 1
  • 1
Dev-iL
  • 23,742
  • 7
  • 57
  • 99
0

You can also use this:

box((axes(1),'off')