How would one clip a DateListPlot to a certain date range?

Suppose I have a list of TimeSeries that may or may not have values in the range 1980-1981. I can plot all the data using DateListPlot, but I would like to display only that part between 1980-1981.

I have tried using TimeSeriesWindow, but it throws an error when the TimeSeries has no values in the window.

  • 4
    $\begingroup$ Wouldn't setting an appropriate PlotRange inside the DateListPlot do what you want? $\endgroup$
    – MarcoB
    Commented Jun 8, 2020 at 19:49
  • $\begingroup$ It throws an error for me. I think due to some of the timeseries not having any values in that range. $\endgroup$
    – Ruben
    Commented Jun 8, 2020 at 19:54
  • 2
    $\begingroup$ Well then time to share your data and code, cause otherwise we are guessing here :-) $\endgroup$
    – MarcoB
    Commented Jun 8, 2020 at 19:57
  • $\begingroup$ @Ruben what error is being thrown? Does it still give you a plot? Plus, obviously, the code + data you use would be extremely helpful in diagnosing the issue here. $\endgroup$
    – rcollyer
    Commented Jun 8, 2020 at 20:59

1 Answer 1


Setting a PlotRange works for me:

 {RandomFunction[BinomialProcess[1/3], {0, 50}], 
  RandomFunction[BinomialProcess[1/3], {40, 90}]},
 PlotRange -> {{30, 90}, Automatic}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.