# DateListPlot to DateListHistogram

I would appreciate help in easily converting a DateListPlot command into a DateListHistogram command. In principle, given the List, whether a plot where each point is represented by a point as versus a horizontal bar for a histogram is just a question of visual representation. I would appreciate a tip on how this can be realized in Mathematica.

• Would this do the trick? DateListPlot[data, InterpolationOrder -> 0] Commented Oct 15, 2020 at 5:54
• Z Ming Ma, please revisit your 18 questions and consider accepting/upvoting the answers posted. If you have not done so already please visit the page Tour to see how to vote/accept.
– kglr
Commented Oct 15, 2020 at 8:12

Using data from chris's answer:

data = {{DateObject[{2016, 10, 1}, "Day", "Gregorian", -5.],
10}, {DateObject[{2016, 10, 15}, "Day", "Gregorian", -5.],
17}, {DateObject[{2016, 10, 30}, "Day", "Gregorian", -5.],
15}, {DateObject[{2016, 11, 20}, "Day", "Gregorian", -5.],
20}};


1. You can create a WeightedData object from data and use it with DateHistogram:

wd = WeightedData @@ Transpose[data];

DateHistogram[wd, {15, "Day"}]


Altenatively, specify your own bin delimiters:

binlims = Append[ wd["InputData"],
DatePlus[wd["InputData"][[-1]], {1, "Month"}]];

DateHistogram[wd, {binlims}]


2. You can use DateListStepPlot:

DateListStepPlot[data, Filling -> Axis]


Use the second argument to specify the steps:

Column[DateListStepPlot[data, #, Filling -> Axis,
PlotLabel -> Style[#, 16], ImageSize -> Large, AspectRatio -> 1/3,
PlotRange -> {{"Sep 1, 2016", "Dec 15, 2016"}, All}] & /@
{Center, Left, Right}]


• Nice! Any idea why the last bin is plotted differently in my answer? Commented Oct 15, 2020 at 7:27
• @chris, you need to add a data point to the right with the same value as the last data point to get a similar picture when you use InterpolationOrder -> 0 because data is not extrapolated automatically. (I think this inconvenience is one of the reasons for introducing ListStepPlot and DateListStepPlot).
– kglr
Commented Oct 15, 2020 at 8:05
data = {{DateObject[{2016, 10, 1}, "Day", "Gregorian", -5.],
10}, {DateObject[{2016, 10, 15}, "Day", "Gregorian", -5.],
17}, {DateObject[{2016, 10, 30}, "Day", "Gregorian", -5.],
15}, {DateObject[{2016, 11, 20}, "Day", "Gregorian", -5.], 20}}


DateListPlot[data, InterpolationOrder -> 0, Filling -> Bottom,
FillingStyle -> Pink]


It seems to represent differently the last day though...

• I accept. DateListStepPlot produces the equivalent of the histogram I seek. Thank you very much. Commented Oct 16, 2020 at 5:59
• ZMingMa accepting involves ticking the accept tick on the left to the answer. I would suggest you accept @kglr which is a better answer. Commented Oct 16, 2020 at 6:12
• Yes. I meant to accept Suggestion 2 which is to use DateListStepPlot as a proxy for DateListHistogram. Thanks for the reminder. Z. Ming Ma Commented Oct 17, 2020 at 16:22