3
$\begingroup$

We have the following example

Clear["Global`*"];

data = TimeSeries[{1, 2, 1, 3, 0, 0, 0, 2, 21, 15, 21, 7, 11, 5, 10, 
    18, 73, 38, 103, 21, 35, 31, 46, 31, 35, 94, 71, 48, 78, 71, 74, 
    95, 95, 56, 102, 81, 119, 99, 60, 62, 20, 77, 52, 71, 56, 72, 33, 
    31, 25, 22, 15, 17, 11, 0, 10, 156, 7, 55, 27, 16, 11, 17, 32, 10,
    15, 21}, {"Feb 26, 2020"}];

plot = DateListPlot[Accumulate[data], FrameTicks -> {{Automatic, Automatic}, 
       {System`DateListPlotDump`DateTicks[data /@ {"FirstDate", "LastDate"}, 
       10, {"Day", "/", "Month"}] &, Automatic}}, Mesh -> All, ImageSize -> 500]

When I run the above code in version 11.3, I get the correct output

enter image description here

However, when I run it with version 12.0, I get this one

enter image description here

with the error message: "A ticks specification in the value of FrameTicks should be None, Automatic, a function, or a list of ticks."

Is there a way to make the code run properly also in version 12.0?

$\endgroup$
4
$\begingroup$

If you remove & from System`DateListPlotDump`DateTicks[...]& it works both in version 11.3 and in version 12.1:

DateListPlot[Accumulate[data], FrameTicks -> {{Automatic, Automatic}, 
       {System`DateListPlotDump`DateTicks[data /@ {"FirstDate", "LastDate"}, 
       10, {"Day", "/", "Month"}] , Automatic}}, Mesh -> All, ImageSize -> 500]

enter image description here

To get the ticks on the top frame right, you can do:

dticks=System`DateListPlotDump`DateTicks[data /@ {"FirstDate", "LastDate"}, 
       10, {"Day", "/", "Month"}] ;

DateListPlot[Accumulate[data], 
  FrameTicks -> {{Automatic, Automatic}, {dticks,dticks}},
  FrameTicksStyle->{{Automatic,Automatic},{Automatic, FontOpacity->0}},
  Mesh -> All, ImageSize -> 500]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Great! But just out of curiosity, why there is a difference between the two versions? $\endgroup$ – Vaggelis_Z May 2 at 11:51
  • $\begingroup$ I see an issue. The number of ticks and their positions in the upper axis do not match those of the lower axis. $\endgroup$ – Vaggelis_Z May 2 at 11:53
  • $\begingroup$ @Vaggelis_Z, I don't know why your original version stopped working in v12.1. I updated with a work-around for the top frame-ticks issue. $\endgroup$ – kglr May 2 at 12:09

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.