1
$\begingroup$

In Mathematica 7 frame ticks from a DateListPlot were amenable to editing. How can I obtain this information from DateListPlot in Mathematica 11?

For example, extracting frame ticks like so:

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

Mathematica 7 output - easy to edit and replace.

{FrameTicks -> {{Automatic, Automatic},
   {{{3368736000, "Oct 02"}, {3369945600, "Oct 16"}, {3371155200, "Oct 30"},
     {3372364800, "Nov 13"}, {3373574400, "Nov 27"}, {3369340800, ""},
     {3370550400, ""}, {3371760000, ""}, {3372969600, ""}},
    {{3368736000, ""}, {3369945600, ""}, {3371155200, ""}, {3372364800, ""},
     {3373574400, ""}, {3369340800, ""}, {3370550400, ""}, {3371760000, ""},
     {3372969600, ""}}}}}

Mathematica 11 output - not in plain format.

{FrameTicks -> {{Automatic, Automatic},
   {Charting`FindScaledTicks[
      (Charting`getDateTicks[Automatic, {Automatic},
          (DateList /@ {##1} &)[##1], None, 5, {{0.0125, 0}, {0.0075, 0}},
          Automatic] &)[##1], {Identity, Identity}] &,
    Charting`ScaledFrameTicks[
      (Charting`getDateTicks[
          Charting`getDateTicks[Automatic, {Automatic},
            (DateList /@ {##1} &)[##1], None, 5, {{0.0125, 0}, {0.0075, 0}},
            Automatic] &, {Automatic}, (DateList /@ {##1} &)[##1], None, 5,
          {{0.0125, 0}, {0.0075, 0}}, None] &)[##1], {Identity, Identity}] &}}}
$\endgroup$
2
  • 1
    $\begingroup$ something to start with: Function[plotInput, Options[DateListPlot[plotInput], FrameTicks][[1, 2, 2, 1]] @@ plotInput[[{1, -1}, 1]] ]@{{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12}, {{2006, 10, 30}, 15}, {{2006, 11, 20}, 20}} don't know what is the proper workflow. $\endgroup$
    – Kuba
    Commented Feb 21, 2017 at 11:45
  • $\begingroup$ @Kuba Terrific! It works, although I haven't figured out how. Thanks $\endgroup$ Commented Feb 21, 2017 at 12:04

1 Answer 1

1
$\begingroup$

Ticks function is fed with Sequence[min, max]. So,

ticksfun = 
Charting`FindScaledTicks[(Charting`getDateTicks[
    Automatic, {Automatic}, (DateList /@ {##1} &)[##1], None, 
    5, {{0.0125, 0}, {0.0075, 0}}, Automatic] &)[##1], {Identity, 
 Identity}] &;

result:

In[4]:= ticksfun[{2006, 10, 1}, {2006, 11, 20}]

Out[4]= {{3.36874*10^9, "Oct 02", {0.00833333, 0}}, {3.36995*10^9, 
"Oct 16", {0.00833333, 0}}, {3.37116*10^9, 
"Oct 30", {0.00833333, 0}}, {3.37236*10^9, 
"Nov 13", {0.00833333, 0}}, {3.37357*10^9, 
"Nov 27", {0.00833333, 0}}, {3.36874*10^9, 
Spacer[{0, 0}], {0.00833333, 0}}, {3.36934*10^9, 
Spacer[{0, 0}], {0.00833333, 0}}, {3.36995*10^9, 
Spacer[{0, 0}], {0.00833333, 0}}, {3.37055*10^9, 
Spacer[{0, 0}], {0.00833333, 0}}, {3.37116*10^9, 
Spacer[{0, 0}], {0.00833333, 0}}, {3.37176*10^9, 
Spacer[{0, 0}], {0.00833333, 0}}, {3.37236*10^9, 
Spacer[{0, 0}], {0.00833333, 0}}, {3.37297*10^9, 
Spacer[{0, 0}], {0.00833333, 0}}}
$\endgroup$

Your Answer

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

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