I am making a ListPlot
, in which the x-axis is the result of AbsoluteTime
. I want the tick text to be human-readable by applying DateString
, but don't want to mess with the automatic tick length. Is this possible? Thanks!
Answer
Unless you specify the tick mark length in your tick specifications tick marks are rendered with default length and style.
tickF = {#, DateString[#, {"MonthNameShort", " ", "Day", "/", "YearShort"}]} & /@
AbsoluteTime /@ DateRange[##, {10, "Day"}] &;
Example data:
data = {{3368649600, 8}, {3369427200, 10}, {3370291200, 12}, {3370636800, 14},
{3371673600, 15}, {3372537600, 20}};
If you have to use ListPlot
:
ListPlot[data, Frame -> True, Axes -> False, PlotRange -> Full,
FrameTicks -> {tickF, Automatic, Automatic, Automatic},
GridLines -> {First /@ tickF[##] &, None}]
If not, DateListPlot
is more convenient to use for your data structure:
DateListPlot[data, PlotRange -> Full,
FrameTicks -> {tickF, Automatic, Automatic, Automatic}]
Comments
Post a Comment