Set plot axes to be positive in both directions

How can I set the axes of a plot to be positive in both directions, along the lines of this image? I've looked through some questions on how to change the axis direction (here, here and here) but they obviously don't fully answer my problem, and I've not got further than the options given in those questions. Presumably the answer lies in the Ticks function, but I'm not sure how to implement it.

Edit

I am aware of custom labels and tick positions from the documentation, but am curious about a more automatic way to do it. I was thinking along the lines of the accepted answer to How to change the axes' origin and direction?, where this is given as a way of reversing the axis direction.

x = Sin /@ Range[0, 2 π, 0.1];
ListPlot[-x, Ticks -> {Automatic, Function[{xmin, xmax},
Table[{i, -i, {0.02, 0}}, {i, N@FindDivisions[{xmin, xmax}, 10]}]]}]

Is there a similar method I could use based on xmin, xmax and N@FindDivisions[], or is custom labels the way forward?

• Have you seen the Ticks option? May 16 '14 at 16:52
• I have, perhaps to clarify, how would I use the ticks option to do this? May 16 '14 at 16:56
• @blochwave Did you read the documentation on it? You need to specify tick positions with custom labels. See the docs on how, last example under Scope -> Tick positions and labeling. May 16 '14 at 17:17
• I did, I was wondering if there was a way to do it based on xmin, xmax and N@FindDivisions? As in #3 of the accepted answer here: mathematica.stackexchange.com/questions/3747/… - I've updated my question to clarify this, sorry that it wasn't clear. May 16 '14 at 17:35

Here is one way to do what you are asking for.

tickSpec[i_Integer] /; Mod[i, 10] == 0 := {i, Abs[i]}
tickSpec[i_Integer] := {i, ""}
With[{nTicks = 13},
ticks[xmin_, xmax_] := Table[tickSpec @ i, {i, FindDivisions[{xmin, xmax}, nTicks]}]]

Plot[{}, {x, -30, 30},
PlotRange -> {Full, {-30, 30}},
AspectRatio -> Automatic,
Frame -> True,
Axes -> False,
FrameTicks -> {{ticks, None}, {ticks, None}}] • That's wonderful, thank you! May 17 '14 at 8:30