Group Abstract Group Abstract

Message Boards Message Boards

1
|
4.4K Views
|
2 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Preventing DateListPlot from automatically connecting data segments?

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).

enter image description here

Attachments:
POSTED BY: Tsai Ming-Chou
2 Replies

Thank you~~~This solved my problem~~

I will learn more about the document later!

POSTED BY: Tsai Ming-Chou

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:

enter image description here

POSTED BY: Nikolay Shilov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard