1
votes

Provided with some code like the following:

x=1:.5:10
plot(x,sin(x))
set(gca,'box','on')

I'm trying to get the left axis to maintain it's tick marks and the right axis to have none.
I know I don't want to do the following:

set(gca,'box','off')
set(gca,'Ytick','[]') %this turns off the left and right axes tick marks. I just want the right off.

I would really,really prefer to not use plotyy. Any help would be appreciated. Are creating dumby axes the only option here? http://www.mathworks.com/matlabcentral/newsreader/view_thread/261486

1

1 Answers

1
votes

I think that you are stuck using a dummy axes (or a variety of even more unappealing options).

FWIW, the code required is only a few lines; the shortest I can get it is below:

a1 = axes('box','on','xtick',[],'ytick',[]);  %Under axis, used as background color and box;
a2 = axes();        %Over axis, used for ticks, labels, and to hold data
propLink = linkprop([a1 a2],'position');      %Keep the positions the same
x=1:.5:10                                     %Make and plot data
plot(a2, x,sin(x))
set(a2,'box','off','color','none');           %Set top axes props last ("plot" overrides some properties)