I have a pandas table with a start and end time for each entry. They don't intersect, but range from seconds to days. I want to visualize them, ideally the x-Axis being the date on which they occus, and the y-axis the time. However, I haven't found a good way to achieve this.

One thought I had were using Boxplots (one Box with one start and one endtime per entry) and grouping by [year, month, day], however this idea doesn't work when the interval starts and ends on a different day.


2 Answers 2


Wolfram recently released a free Wolfram Engine that can be called in Python (and other languages) so you can use its functions like TimelinePlot.

First get some dateIntervals by using the start and end dates of 2017 "TropicalStorm" hurricanes.

ec = EntityClass["TropicalStorm", "Hurricanes2017"];
timeIntervals = Interval /@ EntityValue[ec, {"StartDate", "EndDate"}];

timeIntervals contains Intervals of DateObjects. The first 3 of these are

timeIntervals[[;; 3]]

Mathematica graphics

A basic TimelinePlot of timeIntervals gives


Mathematica graphics

However, TimelinePlot has many options to customise it. For example, take timeIntervals, GatherBy "Month", SortBy the first date of first interval in each set (see Part), and add an Automatic LineLegend using the "MonthShortName"s of each set as legend keys.

  byMonth = 
   SortBy[#[[1, 1, 1]] &]@GatherBy[timeIntervals, DateValue[#[[1, 1]], "Month"] &]
  PlotLegends -> 
   LineLegend[Automatic, DateValue[#[[1, 1, 1]], "MonthNameShort"] & /@ byMonth]

Mathematica graphics

Hope this helps.

  • $\begingroup$ This doesn't seem to work from python. Evaluating the TimelinePlot function just returns a Graphics object. Very cool vis though. $\endgroup$
    – Jeff
    May 9, 2020 at 4:11
  • 1
    $\begingroup$ @Jeff If running in Python then you need to render the Graphics object in a Raster Image Formats or Vector Graphics Formats; wolfSession.evaluate( wl.Export( '<path with image filename>', graphics_object ) ) $\endgroup$
    – Edmund
    May 9, 2020 at 11:49

Without knowing the specifics I can only suggest general ideas:

  • the most natural representation is a one dimension line, with each entry simply represented for instance as a colored or bold segment corresponding to its start and end time. Assuming that the full time span is not too long, this is ok since entries don't overlap. Short entries will appear only as a dot.
  • if appropriate, an alternative would be to represent the duration on the Y axis and use boxplots to represent a set of entries by unit of time on the X axis, for instance week or month. The disadvantage is that this wouldn't represent for instance the time of the day or day of the week at which entries occur.

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.