2
$\begingroup$

How could I move axis and tick labels from the left to the right vertical axis, while retaining ticks on both vertical axes, but removing ticks, axis labels, and tick labels from the top and bottom axes?

See the following example:

Plot[
  Sin[x]^3, {x, 0, 10 π}, Frame -> True, 
  FrameLabel -> {"x", "y"},
  FrameTicks -> {{True, True}, {True, True}}
]
$\endgroup$
4
  • $\begingroup$ try Plot[Sin[x]^3, {x, 0, 10 Pi}, Frame -> True, FrameLabel -> {{None, "x"}, {"y", None}}, FrameTicks -> {{False, All}, {False, False}}]? $\endgroup$
    – kglr
    Jan 4, 2022 at 20:08
  • $\begingroup$ Ticks on the left y-axis are also wanted. $\endgroup$
    – SciJewel
    Jan 4, 2022 at 20:24
  • $\begingroup$ Try: Plot[Sin[x]^3, {x, 0, 10 Pi}, Frame -> True, FrameLabel -> {{None, "x"}, {"y", None}}, FrameTicks -> {{All, All}, {False, False}}] $\endgroup$ Jan 4, 2022 at 21:08
  • $\begingroup$ No number on the left axis @ Daniel Huber $\endgroup$
    – SciJewel
    Jan 4, 2022 at 21:34

1 Answer 1

3
$\begingroup$

1. Use FrameTicks -> {All, {None, None}} and hide unwanted tick labels using FontOpacity -> 0 in FrameTicksStyle :

Plot[Sin[x]^3, {x, 0, 10 Pi}, Frame -> True, 
 FrameTicks -> {All, {None, None}}, 
 FrameTicksStyle -> {{FontOpacity -> 0, Automatic}, Automatic},
 FrameLabel -> {{None, "x"}, {"y", None}}] 

enter image description here

2. Use Charting`ScaledFrameTicks[{Identity, Identity}] to generate ticks without labels:

Plot[Sin[x]^3, {x, 0, 10 Pi}, Frame -> True, 
 FrameTicks -> {{Charting`ScaledFrameTicks[{Identity, Identity}], All}, {None, None}},
 FrameLabel -> {{None, "x"}, {"y", None}}]

enter image description here

$\endgroup$
5
  • $\begingroup$ The left and right axes are perfect what I want, but no ticks and labels are required on the bottom and top axes. $\endgroup$
    – SciJewel
    Jan 4, 2022 at 21:32
  • $\begingroup$ @SciJewel, please see the update. $\endgroup$
    – kglr
    Jan 4, 2022 at 22:55
  • $\begingroup$ Wow! Thanks, Kglr! Always helpful! $\endgroup$
    – SciJewel
    Jan 4, 2022 at 23:07
  • $\begingroup$ how to rotate the tick labels (-1, -0.5, 0, 0.5, 1) in the above plot? Is this possible? $\endgroup$
    – SciJewel
    Jan 5, 2022 at 8:05
  • $\begingroup$ @SciJewel, define rotatedFrameLabels = Charting`ScaledTicks[{Identity, Identity}][##] /. l_NumberForm :> Rotate[l, 90 Degree] &; and replace All with {rotatedFrameLabels, rotatedFrameLabels} in method 1 and with rotatedFrameLabels in method 2. $\endgroup$
    – kglr
    Jan 5, 2022 at 10:08

Your Answer

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

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