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$
1
  • 2
    $\begingroup$ Looking at the FullForm of your DateListPlot might give you some ideas... $\endgroup$ Jun 27, 2012 at 15:01

1 Answer 1

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$
1
  • 3
    $\begingroup$ or plot /. (FrameTicks -> _) -> (FrameTicks -> ticks) to eliminate the 2nd and 3rd last lines. $\endgroup$ Jun 27, 2012 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.