How do I crop white space from datetime plots ?

3 views (last 30 days)
Slawomir Kania
Slawomir Kania on 20 Jun 2018
Edited: dpb on 21 Jun 2018
I have been trying to plot some datetime data and have been using datetime table with data table to plot.
The x-axis shows a white area before and after data which does not show while using regular format, not datetime.
So how do I crop white parts from the subplots ? I cannot do it using the zoom in tool because it disalign with other plots. Also axis align does not seem to work. Any help is apreciated.

Answers (1)

dpb
dpb on 20 Jun 2018
Edited: dpb on 21 Jun 2018
xlim([datetime(yL,mL,dL) datetime(yR,mR,dR)])
where yX,mX,dX are year/month/date for Left/Right axes limits desired. Presuming using recent-enough release--if you get error saying something about "must use a double", that's an intermediary release wherein the plot function accepts datetime but the axes are still in datenum form internally. In that case, substitute datenum for datetime
ADDENDUM
Bad eyes...just noticed that the desired start/stop times include times, not just days. Same idea, just need to use the six-element date vector for input rather than the three...
xlim([datetime(yL,mL,dL, hL,ML,sL) datetime(yR,mR,dR, hR,MR,sR)])
for hr, min, sec.
ERRATUM
Also noticed and corrected a typo in original of having copied the opening [ to the second argument of xlim which would have unbalanced matching brackets.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!