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!

  • 2
    $\begingroup$ DateListPlot? $\endgroup$ – Kuba Mar 2 '15 at 10:42
  • $\begingroup$ Don't know what you mean with tick length here, but if you're worried about the size of the label perhaps you could use Rotate? $\endgroup$ – Sjoerd C. de Vries Mar 2 '15 at 11:49

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}]

enter image description here

If not, DateListPlot is more convenient to use for your data structure:

DateListPlot[data, PlotRange -> Full, 
  FrameTicks -> {tickF, Automatic, Automatic, Automatic}]

enter image description here

| 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.