I have some observation data. Sometimes there is no observation data for a specific date.
Usually, DateListPlot will automatically connect different data line segments (as shown in the figure). But I don’t want this.
Get["data.mx",data];
DateListPlot[data,ImageSize -> Large]
How to prevent DateListPlot from automatically connecting these data segments (still retaining the time stamp on the horizontal axis)?
Note: I have attached the MX file. The data range is from 2019/10/18 to 2019/10/19 to 2019/10/26, and there are three days without data (10/21, 10/22, 10/23).
data.mx (10.3 KB)
You can pass an option Joined -> False to the DateListPlot function, but it will eliminate all connections (including those inside your data segments) in the graph. If you want to keep them you’d have to divide your data into pieces manually and then plot them using DateListPlot[{datarange1, datarange2, ...}], as far as I know.
P.S. Or else you can use some of the WL clusterizing algorithms to divide your data automatically. For example,
datasets = FindClusters[data,
DistanceFunction -> Function[{o1, o2}, QuantityMagnitude[DateDifference[o2[[1]], o1[[1]]]]]
];
DateListPlot[datasets]
produced the following picture:
Thank you~This solved my problem
I will learn more about the document later!