3
$\begingroup$

I am trying to plot two functions on the same plot with two different y-axes. I have used this answer and the result is ok; now I need to add the axes label on both the y-axes and on the x-axis. FrameLabel won't work. How can I do it?

Here is my code:

range = {Range[1,10],Range[1,10]};
number = {Range[1,10],Range[1,10]};

p1 = ListLogLogPlot[number, Joined -> True, PlotStyle -> Blue, 
   ImagePadding -> 25, Frame -> {True, True, True, False}, 
   FrameStyle -> {Automatic, Blue, Automatic, Automatic}];
p2 = ListLogLogPlot[range, Joined -> True, PlotStyle -> Red, 
   ImagePadding -> 25, Axes -> False, 
   Frame -> {False, False, False, True}, 
   FrameTicks -> {None, None, None, All}, 
   FrameStyle -> {Automatic, Automatic, Automatic, Red}];
Overlay[{p1, p2}]
$\endgroup$
  • $\begingroup$ Show the code you already have. $\endgroup$ – MarcoB Jul 16 '18 at 14:56
  • 1
    $\begingroup$ Check out the AxesLabel option. $\endgroup$ – kickert Jul 16 '18 at 15:37
  • $\begingroup$ I played around with your code a bit and it seems it is the Frame option that is causing problems with the AxesLabel $\endgroup$ – kickert Jul 16 '18 at 20:41
2
$\begingroup$
Labeled[Overlay[{p1, p2}], 
  Style[#, 16, #2, ShowStringCharacters -> False] & @@@ 
   Transpose[{{Rotate["Label1", 90 Degree], 
     Rotate["Label2", 90 Degree], "XAxis"}, {Blue, Red, Black}}], 
 {Left, Right, Bottom}]

enter image description here

$\endgroup$
  • $\begingroup$ @mattiav27, updated. $\endgroup$ – kglr Jul 17 '18 at 8:28

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.