Setting plot limits with dates

29 views (last 30 days)
Ziggy
Ziggy on 5 Aug 2013
Hi,
I have two data sets, which have different ranges and wish to plot one below the other with the same axes limits. I have tried the following to no avail. This should be an easy fix I'm sure, but I can't figure it out.
%xlim(['31-Oct-2012' '26-April-2013']) - didn't work
%set(axes,'xlimmode',['31-Oct-2012' '26-April-2013']) - didn't work
axis([735205 735305 0 80]) - no effect at all
subplot(2,1,1), plot(rvhh1); legend('off');title('1-Month Henry Hub Realized Volatility')
subplot(2,1,2), plot(tempfts); legend('off'); title('Chicago: Ten-Year Daily Normals v Daily Mean');
Thanks for the help!

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 5 Aug 2013
Look at this example
close
x1=datenum('31-Oct-2012')
x2=datenum('26-April-2013')
x=x1:x2
y=sin(0.1*x)
plot(x,y)
xlim([x1,x2])
xticks=get(gca,'xtick');
set(gca,'xticklabel',cellstr(datestr(xticks))')

Categories

Find more on 2-D and 3-D Plots 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!