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
$\begingroup$
$\endgroup$
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
1
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]
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]
-
$\begingroup$ Thank you so much, that really helps a lot $\endgroup$ Commented Aug 14, 2020 at 4:17