Message Boards Message Boards

2 Replies
2 Total Likes
View groups...
Share this post:

How to surpress timegaps within DateListPlot

Hi, As you can see below the code produces a DateListPlot for some Trading data. In the weekends there no trading and DateListPlot shows this in the plot by skipping these values and connecting the friday and mondays. This of course creates a "gap" between the friday and monday. How can I get the fridays and monday values next to each other? Is there an option to do this?

data = FinancialData["^AEX", {{2015, 1, 1}, {2015, 2, 1}}];

DateListPlot[data, Frame -> False, Ticks -> {data[[All, 1]], Automatic}, DateTicksFormat -> {"Day"}, ImageSize -> {600, 100}, AspectRatio -> 100/600.]

enter image description here

So the gap below between 09 and 12 I would have liked removed

enter image description here

thx for helping

POSTED BY: l van Veen
2 Replies


I am not quite sure whether I understand the problem. Because of the "weekend" there is no trading so there should be no points for the missing days. If your problem is about the plot and you do not want the ticks to be placed like that this might help:


which gives:

enter image description here

If you want to "delete the weekends" from the time series, and you think of the x-axis as trading days you can just plot the values:

data[[All, 2]] // ListLinePlot

enter image description here

A more complete solution might be this:

ListLinePlot[data[[All, 2]], Frame -> True, PlotStyle -> Directive[Red, Thickness[0.01]], 
FrameTicks -> {{All, None}, {Table[{j, Rotate[DateString[DateObject@DatePlus[{2015, 1, 1}, 
{j, "BusinessDay"}]], Pi/2]}, {j, 1, Length[data], 1}], None}}]

enter image description here

I am sure that there is a better way of doing it, but this one gives you quite a bit of control over the figure.



POSTED BY: Marco Thiel

Hi Marcus, Thx this should work for me. It feels a bit like cheating but I'm fine with that :)

POSTED BY: l van Veen
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract