1
$\begingroup$

I am trying to plot the y-axis value as a percent form. By using PercentForm for the Ticks which I followed Changing tick labels to percent, I can plot the y-axis in percent. However, this approach only works when I do not specify the "Frame->True". Can anybody explain this to me? Thanks

$\endgroup$

1 Answer 1

1
$\begingroup$

You need to use the option FrameTicks instead of Ticks:

ticks = {#, ToString[PercentForm[#]]} & /@ Range[0, 1, .1];

Plot[x, {x, 0, 1}, 
  FrameTicks -> {{ticks, Automatic}, {Automatic, Automatic}}, 
  Frame -> True]

enter image description here

Alternatively, modify the labels of automatically-generated major ticks:

tickF = Charting`ScaledTicks["Linear"][##] /.
  {a_, _NumberForm, b___} :> {a, ToString @ PercentForm[a], b} &;

Plot[x, {x, 0, 1}, 
 FrameTicks -> {{tickF, Automatic}, {Automatic, Automatic}}, 
 Frame -> True]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you so much, that really helps a lot $\endgroup$ Commented Aug 14, 2020 at 4:17

Your Answer

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

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