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 Jun 8 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 Jun 8 at 19:54
  • 2
    $\begingroup$ Well then time to share your data and code, cause otherwise we are guessing here :-) $\endgroup$ – MarcoB Jun 8 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 Jun 8 at 20:59

Setting a PlotRange works for me:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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