12
$\begingroup$

DateListPlot very nicely chooses major and minor frame tick and frame tick label/markers.

I am building a custom graphics function where either the x or y axis is time and I would like to use whatDateListPlot provides. How can I do this without simply overlaying and using Show?

$\endgroup$
  • 2
    $\begingroup$ Looking at the FullForm of your DateListPlot might give you some ideas... $\endgroup$ – Sjoerd C. de Vries Jun 27 '12 at 15:01
10
$\begingroup$

Options will do it:

data = {{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12},
   {{2006, 10, 30}, 15}, {{2006, 11, 20}, 20}};
plot = DateListPlot[data];
Options[plot, FrameTicks]

For example, modifying the contents of FrameTicks:

data = {DateList[{2006, #, 1}], #} & /@ Range[40];
plot = DateListPlot[data];
ticks = FrameTicks /. Options[plot, FrameTicks];
ticks[[2, 1, All, 2]] = Style[#, Red] & /@ ticks[[2, 1, All, 2]];
pos = Position[plot, FrameTicks];
plot[[Sequence @@ Most[First@pos]]] = FrameTicks -> ticks;
plot

enter image description here

$\endgroup$
  • 3
    $\begingroup$ or plot /. (FrameTicks -> _) -> (FrameTicks -> ticks) to eliminate the 2nd and 3rd last lines. $\endgroup$ – Mike Honeychurch Jun 27 '12 at 21:55

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.