plotyy: Does matlab recognize gaps in date time line when plotting dates on y-axis?

9 views (last 30 days)
Hey everyone,
I have a simple question that I cannot seem to find the answer to:
When I have a vector that is made up of chronological dates (with a few dates missing) and I use this vector in plotyy to plot something - does matlab recognize that there are a few dates missing and therefore plots a hole in the plot? For example I have sales data for each day of eleven month of the year, july is missing. When I plot the data with plotyy and use my date vector that comprises all daily dates except for the july dates - will I be able to see the gap in my plot? Or does matlab simply eliminate the month july since it cannot find information about july in the data vector or the date vector? So I won't be able to see the gap graphically?
I hope my question is clear... I had some problems formulating it in English...
Thanks a lot!!

Answers (2)

Roger Wohlwend
Roger Wohlwend on 17 Oct 2014
Matlab plots the data you provide. Matlab does not check for missing data or something on its own. However, it is actually quite simple to detect the kind of missing data your talking of. Just do the following:
d = diff(TimeVector)
If you have daily data, then most elements in the vector d are equal to 1 or 3. If there is a whole month missing, then one element is the vector is 30 or something like that. So all you have to do is check the vector d for outliers. These outliers tell you that there is missing data.

Star Strider
Star Strider on 17 Oct 2014
Edited: Star Strider on 17 Oct 2014
If you want to create a gap for July, plot the two series separately:
ds = datenum([2014 01 01; 2014 06 30; 2014 08 01; 2014 12 31]); % Create Data
dv = {ds(1):7:ds(2); ds(3):7:ds(4)};
sv = {sin(2*pi*dv{1}/75); sin(2*pi*dv{2}/75)};
figure(1)
plot(dv{1}, sv{1}) % Plot Jan-Jun
hold on
plot(dv{2}, sv{2}) % Plot Aug-Dec
hold off
grid
datetick('x', 'mm/dd')
produces:

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!