2
$\begingroup$

I'm trying to do an overlay plot in the vein of the solutiosn given in (Frame labels for Overlay of two plots to look like plot with two y-axes), but with the new mathematica 11 version it seems that it is not possible to get tick labeling on the right side. Is there another way to do this now?

Specifically, using:

p1 = Plot[5 Sin[t] + 95, {t, 1, 10}, PlotStyle -> {Black}, 
  Axes -> None, BaseStyle -> {FontSize -> 14}, 
  Ticks -> {{}, {94, 96, 98, 100}}, 
  ImagePadding -> {{50, 50}, {20, 2}}, 
  FrameTicks -> {None, All, None, None}, 
  Frame -> {True, True, False, False}, 
  PlotLegends -> 
   Placed[LineLegend[{Black, 
      Directive[Dashed, Black]}, {"First thing", "Other thing"}], 
    Bottom], FrameLabel -> {{"First thing", None}, {"Stuff", None}}]

 p2 = Plot[5 Cos[t] + 5, {t, 1, 10}, Axes -> None,
  PlotStyle -> {Directive[Black, Dashed]}, 
  BaseStyle -> {FontSize -> 14}, Ticks -> {{}, {2, 4, 6, 8, 10}}, 
  FrameTicks -> {None, None, None, All}, 
  ImagePadding -> {{50, 50}, {20, 2}}, 
  Frame -> {False, False, False, True}, 
  FrameLabel -> {{None, "Thing"}, {None, None}}] 

p = Overlay[{p1, p2}]

no longer gives tick labeling on the right side as shown in the link.

$\endgroup$
  • $\begingroup$ It seems that old 4element spec for FrameTicks is not supported anymore. It works with FrameTicks -> {{None, All}, {None, None}} though. $\endgroup$ – Kuba Aug 25 '16 at 13:24
  • $\begingroup$ p.s. notice that the code essential for that question can be reduced to Plot[ Cos[t], {t, 1, 10}, FrameTicks -> {All, All, All, All}, Frame -> True], try it next time :) $\endgroup$ – Kuba Aug 25 '16 at 13:26
  • $\begingroup$ The issue is with the way FrameTicks are specified in your code. The documentation says in the detail section that the correct form is FrameTicks -> {{left,right},{bottom,top}}. $\endgroup$ – Sascha Aug 25 '16 at 13:26
3
$\begingroup$

The proper syntax for FrameTicks is

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

In previous versions you could get away with using an alternative {bottom, left, top, right}, (correct me if I have those in the wrong order) but no longer.

Keeping your p1 definition,

p2 = Plot[5 Cos[t] + 5, {t, 1, 10}, Axes -> None, 
   PlotStyle -> {Directive[Black, Dashed]}, 
   BaseStyle -> {FontSize -> 14}, Ticks -> {{}, {2, 4, 6, 8, 10}},
   FrameTicks -> {{None, All}, {None, All}},
   ImagePadding -> {{50, 50}, {20, 2}}, 
   Frame -> {False, False, False, True},
   FrameLabel -> {{None, "Thing"}, {None, None}}];
p = Overlay[{p1, p2}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thanks everyone, that did the trick. $\endgroup$ – Jonah Gollub Aug 26 '16 at 20:40

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