Plot time along the y-axis?
I can't seem to find a built-in way so I propose an extension of my old axisFlip
routine:
axisFlip = # /. {x_Point | x_Line | x_GraphicsComplex :> MapAt[# ~Reverse~ 2 &, x, 1],
x : ((PlotRange | FrameTicks) -> _) :> x ~Reverse~ 2} &;
DateListPlot[{1, 1, 2, 3, 5, 8, 11}, {2000, 8}] // axisFlip
DateListPlot[{1, 1, 2, 3, 5, 8, 11}, {2000, 8}, Joined -> False] // axisFlip
This should work with TimeObject
as well; let me know if it doesn't.
It looks like DataListPlot
does not understand TimeObject
s. You can convert them to Quantity
"Hours"
and plot this instead.
data = {{DateObject[{2016, 1, 1}], TimeObject[{6, 0, 0}]},
{DateObject[{2016, 1, 2}], TimeObject[{8, 0, 0}]}};
hrData = MapAt[UnitConvert[Total@DateValue[#, {"Hour", "Minute", "Second"}, Quantity], "Hours"] &, {All, 2}]@data
{{DateObject[{2016, 1, 1}], Quantity[6, "Hours"]}, {DateObject[{2016, 1, 2}], Quantity[8, "Hours"]}}
Then plot hrData
DateListPlot[hrData, FrameLabel -> Automatic,
DateTicksFormat -> {"MonthNameShort", " ", "Day"}]
The y-axis is in hours and gets an automatic "h" frame label.
Hope this helps.