# Percentage axis ticks

To create a percentage axe in some plot I use this Ticks configuration:

ListPlot[
Range[0,1,0.1]
,Ticks->{Automatic, {#,If[IntegerPart@Mod[100#,10]==0,Row[{100#,"%"}],""]}&/@Range[0,1,0.05]}
]


1. Non automatic range scale
2. No subticks with different sizes
3. It's nor elegant nor simple

I miss a Mathematica TicksFunction or equivalent, so I could have better control over it. I also tried something like: ListPlot[Quantity[Range[0, 1, 0.1], "Percent"]] without succes.

Some clue into a better approach?

• Why not just relabelling the ticks ? Commented Jan 15, 2013 at 10:07
• How can I do this? Using... Commented Jan 15, 2013 at 10:09
• Define pc = {#, ToString[100 #] <> " %"} & /@ Range[0, 1, 0.1] and then Ticks -> {Automatic, pc}. Commented Jan 15, 2013 at 10:14
• tks, but in this way you remove the subticks. Commented Jan 15, 2013 at 10:27
• Would it fit to your approach to use the label, i.e. somethin like AxesLabel -> {"your x-axis label", "something in %"} and leave the TicksLabels as they are (and hence keep the MinorTicks ? Commented Jan 15, 2013 at 10:36

In Mathematica 9, I developed a PercentTicks function to solve this problem. Here is an example of how it is used:

ListPlot[Table[{x, x}, {x, 0, .003, 0.0001}],
Ticks -> { Automatic, PercentTicks }]


which gives:

The code is in my github repo.

• Nice code. Tks. Commented Jul 11, 2014 at 2:18

Replace the automatically generated labels to not have to care about generating the ticks yourself and preserve subticks:

percentTicks[plot_] := Module[{xticks, yticks},
{xticks, yticks} = (Ticks /. AbsoluteOptions[plot, Ticks]);
yticks =
yticks /. {y_, lbl_, rest__} /; lbl != "" :> {y, ToString[y*100] <> "%", rest};
Show[plot, Ticks -> {xticks, yticks}]
]

percentTicks@ListPlot[Sort@RandomReal[{0, 1}, {50}]]


• This theoretically works OK, but M version 8 has a bug and AbsoluteOptions doesn't work as expected for Ticks Commented Jan 15, 2013 at 15:21
• @belisarius Got more details on that bug? I have v8 but can't break it.
– ssch
Commented Jan 15, 2013 at 16:22
• Take a look at the x-axis ticks i.sstatic.net/T7kbm.png Commented Jan 15, 2013 at 16:26
• It is v 8.0 BTW Commented Jan 15, 2013 at 16:26
• It's not simple, but I agree it's the best that can be done with MMA until version 9. Tks! 1+ Commented Jan 15, 2013 at 19:53

You can take control of all relevant bits :

pcTicks = {#, ToString[100 #] <> " %", {0.02, 0}} & /@  Range[0, 1, 0.1];
pcSubTicks = {#, "", {0.01, 0}} & /@ (Range[0, 1, 0.1] + 0.05);

ListPlot[Range[0, 1, 0.1], Ticks -> {Automatic, Join[pcTicks, pcSubTicks]}]
`