5
$\begingroup$

FrameTicks used to support the positioning of strings along the axes of ListPlot. For example:

x1 = 2 Accumulate[RandomVariate[NormalDistribution[0, 1], 100]];
x2 = 5 Accumulate[RandomVariate[NormalDistribution[0, 1], 100]];

SetOptions[ListPlot, ImageSize -> 500, Frame -> True, Joined -> True, 
 GridLines -> Automatic, PlotStyle -> {{Thick, Red}, {Thick, Blue}}, 
 PlotRange -> {{0, 100}, {-50, 50}}, 
 FrameLabel -> {"Progress from Beginning to End", "Red Line", "Descriptive 
 Title", "Blue line"}, LabelStyle -> {12, FontFamily -> "Arial"}];

ListPlot[{x1, x2}, FrameTicks -> {{{0,"Beginning"},{25,"Early"},{50, 
 "Middle"}, {75,"Almost\nFinished"},{100, "Finished"}}, Automatic, None, 
 Automatic}
]

enter image description here

Recently, FrameLable has changed to require ->{{left,right},{bottom,top}]. If I make these changes to FrameLable and re-evaluate ListPlot I get the plot below. FrameTicks doesn't work anymore. What happened? Is the functionality gone? Moved somewhere else?

enter image description here

$\endgroup$
7
$\begingroup$

I didn't even knew you could write it like that in the past. But like you already pointed out, the structure is with nested lists for FrameTicks as well

{{left,right},{bottom,top}]

You should also set the options in the function directly so we just use it:

FrameTicks -> {{Automatic, 
   Automatic}, {{{0, "Beginning"}, {25, "Early"}, {50, "Middle"}, {75,
      "Almost\nFinished"}, {100, "Finished"}}, Automatic}}

or with full code:

x1 = 2 Accumulate[RandomVariate[NormalDistribution[0, 1], 100]];
x2 = 5 Accumulate[RandomVariate[NormalDistribution[0, 1], 100]];

ListPlot[{x1, x2}, 
 FrameTicks -> {{Automatic, 
    Automatic}, {{{0, "Beginning"}, {25, "Early"}, {50, 
      "Middle"}, {75, "Almost\nFinished"}, {100, "Finished"}}, 
    Automatic}}, ImageSize -> 500, Frame -> True, Joined -> True, 
 GridLines -> Automatic, PlotStyle -> {{Thick, Red}, {Thick, Blue}}, 
 PlotRange -> {{0, 100}, {-50, 50}}, 
 FrameLabel -> {"Progress from Beginning to End", "Red Line", 
   "Descriptive 
    Title", "Blue line"}, LabelStyle -> {12, FontFamily -> "Arial"}]

enter image description here

$\endgroup$
  • $\begingroup$ I should have thought of that. I even gave myself a hint, but I didn't take it. This capability is valuable because if you have multiple time series with the values occurring on the same days, you can plot them all in ListPlot and annotate the bottom axes with time labels. It used to be the case that DateListPlot was really slow when plotting long time series. That may not be the case anymore. $\endgroup$ – George Wolfe Oct 2 '17 at 22:11

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.