How can I set the x-axis in a plotyy to "datetick('x','yy') "?

1 view (last 30 days)
Hi,
I'm trying to use plotyy but I need a second line on the first y-axis. I'm doing this with the "line" but this screws up the formatting of the x-axis. My code is as follows:
h = figure(3)
for s=1:6
subplot(3,2,s)
figure(h)
[ax, h1, h2] = plotyy(dates,Y1(:,s),dates,Y2(:,s));
line(dates,Y3(:,s),'parent',ax(1));
%axis tight
xlabel('Year')
datetick('x','yy')
ylabel('Index')
title(Headertext(1,s+1),'FontSize',11)
end
What I want is the x-axis to be labelled in years. But what I get is two overlapping axis. One with the right datetick format, one with just the matlab dates (format 726478 etc.)
any ideas how to get just one, correctly labelled x-axis?
I tried as well using
[ax,h1,h2]=plotyy(dates,Y1(:,s),dates,Y2(:,s));
hold on
set(ax(2),'nextplot','add');
plot(ax(2),dates,Y3(:,s))
xlabel('Year')
datetick('x','yy')
ylabel('Index')
but that didn't work either...

Answers (0)

Categories

Find more on Two y-axis in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!