% Use the form:
[AX,H1,H2] = plotyy(...)
% AX is a handle to both axes
% AX(1) is "first" plot and
% AX(2) is "second" plot
set(AX,'YTick,[]) % empty vector
% will remove BOTH y-axis tick marks
Which version are you using? I don't observe that in 2007a. Are you sure you don't have 'hold on'
keeping a previous axes in place? If you are using plot() and hold on and plotyy, you probably
shouldn't be doing that; instead, check out the Matlab File Exchange (FEX) contribution 'plt'.
e.g.,
plotyy(1:20,rand(1,20),1:100,50*log(rand(1,100)))
Ex: If I move the legend for the left axis outside the plot area will adjust for those functions plotted against the left axis - there are 2 borders and the x values at the bottom are printed twice over top of one another because some functions' plot area is 75% screen width and others are 60%.
The point is that plotting on 2 axes is annoying because matlab doesn't seem to recognize both at once so they do their own thing, and that means putting tick marks on both sides for axis 1.
Yes, it creates two axes in the same position and manipulates the axes properties for the
two graphs.
> Ex: If I move the legend for the left axis outside the plot area will adjust for those
> functions plotted against the left axis - there are 2 borders and the x values at the bottom
> are printed twice over top of one another because some functions' plot area is 75% screen
> width and others are 60%.
> The point is that plotting on 2 axes is annoying because matlab doesn't seem to recognize both
> at once so they do their own thing, and that means putting tick marks on both sides for axis 1.
In versions later than the one you have, coordination between axes is handled more smoothly
by using linkaxes() and (later) linkprop().
I would suggest that you explore the Matlab File Exchange (FEX) contribution 'plt' if
it will run in your Matlab version.
Thanks Walter for suggesting 'plt' as a solution.
And of course I agree that it handles a plot with both
left and right y axes with more ease and flexibility.
(The more important benefits however show up when you
need to plot more than two traces).
Your question about the Matlab version shouldn't be a
factor as it will run in all versions from the latest
all the way back to ver 6.1 (R12.1) which was released
over seven years ago.
And by the way, there is an updated version of plt that
I put up on the FEX a few days ago (my 33rd update since
the first release in 2004).
And for the example you gave:
> plotyy(1:20,rand(1,20),1:100,50*log(rand(1,100)))
To do that with plt, you have to specify which trace
you want to put on the right axis with the 'right'
parameter, as in:
plt(1:20,rand(1,20),1:100,50*log(rand(1,100)),'right',2)
Be sure to ask me if you have any questions or problems
when using plt.
~Paul
paul (at) mennen (dot) org
For example:
[ax, h1, h2] = plotyy(x1, y1, x2, y2);
set(ax(1), 'Ylim', [0 10], 'YTick', [0:2:10]); % sets ticks for right axis at 0,2,4,6,8,10
set(ax(2), 'Ylim', [0 1], 'YTick', [0:0.1:1]); % sets left axis ticks at 0, 0.1, 0.2 etc.
In this example, every other tick mark on the right axis will occur right on top of the ones from the left axis and cover it.
"Brent Selby" <fgw...@gmail.com> wrote in message <gcvivp$pkf$1...@fred.mathworks.com>...
set(gca,'box','off'); %remove the box
set(ax(2), XAxisLocation','top','linewidth',3) %cover the top box manually
set(ax(2),'XTick',[]) %remove the ticks
Michael
"Joe Tyburczy" <color...@gmail.com> wrote in message <ha2kgc$nus$1...@fred.mathworks.com>...
I have found a way to fix that as I got the same need like you. It is amazingly simple:
given some x, y1, y2
>>[ax,h1,h2]=plot(x,y1,x,y2);
>>set(ax(2),'Box','Off'); %remove y1 ticks from the right side
>> set(ax(1),'Box','Off'); @remove y2 ticks from the left side
regards
Tuan A. Phan