0
$\begingroup$

I am trying to make a plot with 3 vertical axes (frame with three labels). The desired plot done in other software is as follow.

enter image description here

Here is my code for Mathematica.

    dAta = Table[{i, RandomReal[{1, 5}], 20, RandomReal[{50, 80}]}, {i, 
    100}];
tEstPt1 = 
 ListPlot[#, ImageSize -> 400, Frame -> {{True, False}, {True, True}},
     FrameTicks -> {{True, None}, {True, True}}(*All*), 
    PlotRange -> {{0, 100}, {0, 6.0}}, Joined -> True, 
    PlotStyle -> Blue, ImagePadding -> {{60, 65}, {60, 10}}, 
    Axes -> False, 
    FrameStyle -> {{Directive[Black, AbsoluteThickness[0.75], 12] , 
       Directive[Black, AbsoluteThickness[0.75], 12]}, {Directive[
        Black, AbsoluteThickness[0.75], 12] , 
       Directive[Black, AbsoluteThickness[0.75], 12]}},
    FrameTicksStyle -> {{Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]], 
       Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]]}, {Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]], 
       Directive[Black, Bold, 12, AbsoluteThickness[0.75]]}}, 
    FrameLabel -> {{Style[#, Black, Bold, 14] &@("Y-label"), 
       None}, {Style[#, Black, Bold, 14] &@("X-label"), 
       None}} ] &@(dAta[[1 ;; 100, {1, 2}]])
tEstPt2 = 
 ListPlot[#, ImageSize -> 400, 
    Frame -> {{False, True}, {False, False}}, 
    FrameTicks -> {{False, All}, {False, False}}(*All*), 
    PlotRange -> {{0, 100}, {0, 40.0}}, Joined -> True, 
    PlotStyle -> Green, ImagePadding -> {{60, 65}, {60, 10}}, 
    Axes -> False, 
    FrameStyle -> {{Directive[Black, AbsoluteThickness[0.75], 12] , 
       Directive[Black, AbsoluteThickness[0.75], 12]}, {Directive[
        Black, AbsoluteThickness[0.75], 12] , 
       Directive[Black, AbsoluteThickness[0.75], 12]}},
    FrameTicksStyle -> {{Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]], 
       Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]]}, {Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]], 
       Directive[Black, Bold, 12, AbsoluteThickness[0.75]]}}, 
    FrameLabel -> {{None, 
       Style[#, Black, Bold, 14] &@("Y1-label")}, {None, 
       None}} ] &@(dAta[[1 ;; 100, {1, 3}]])
tEstPt3 = 
 ListPlot[#, ImageSize -> 400, 
    Frame -> {{False, True}, {False, False}}, 
    FrameTicks -> {{False, All}, {False, False}}(*All*), 
    PlotRange -> {{0, 100}, {20, 90.0}}, Joined -> True, 
    PlotStyle -> Red, ImagePadding -> {{60, 65}, {60, 10}}, 
    PlotRangePadding -> {{0, 20}, {0, 0}}, Axes -> False, 
    FrameStyle -> {{Directive[Black, AbsoluteThickness[0.75], 12] , 
       Directive[Black, AbsoluteThickness[0.75], 12]}, {Directive[
        Black, AbsoluteThickness[0.75], 12] , 
       Directive[Black, AbsoluteThickness[0.75], 12]}},
    FrameTicksStyle -> {{Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]], 
       Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]]}, {Directive[Black, Bold, 12, 
        AbsoluteThickness[0.75]], 
       Directive[Black, Bold, 12, AbsoluteThickness[0.75]]}}, 
    FrameLabel -> {{None, 
       Style[#, Black, Bold, 14] &@("Y2-label")}, {None, 
       None}} ] &@(dAta[[1 ;; 100, {1, 4}]])
Overlay[{tEstPt1, tEstPt2, tEstPt3}]

The axes on the right are overlapping instead of offsetting. The main problem is offsetting the axes.

Please help. Thank you.

$\endgroup$
2
  • 3
    $\begingroup$ possible duplicate: Plot with multiple Y-axes $\endgroup$
    – kglr
    Oct 4, 2018 at 15:09
  • $\begingroup$ Thank you for your link. It is true that the question is duplicate. $\endgroup$
    – yaykhel
    Oct 5, 2018 at 6:25

0

Your Answer

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

Browse other questions tagged or ask your own question.