# How to plot on a symmetric axis/frame

Say one had a function that was itself asymmetric about the abscissa, but one desired to plot it on a symmetric ordinate. How can this be achieved with Plot automatically (without separately computing the limits and providing them to Plot)?

Example The plot of 1/2 serves as a sufficient example.

Table[
Plot[
1/2,
{ x, 0, 1 },
Frame -> { False, True }[[i]],
Axes -> { True, False }[[i]]
],
{ i, 1, 2 }
] But we might want the PlotRange to go from $+1$ to $-1$ instead, like: I did this with the option PlotRange, but short of finding the maximum of the absolute value of the function and setting PlotRange, I don't know how to automate this.

Specifically, is it possible to use Plot in a native manner to do this?

Solution (based on the answer by Szabolcs) Here's a little function that implements the answer.

plotSym[ plot_ ] :=
plot //
{
#,
First[PlotRange /. AbsoluteOptions[#, PlotRange]],
Max@Abs@Last[PlotRange /. AbsoluteOptions[#, PlotRange]]
} & //
Show[ #[], PlotRange -> {#[], (1.2*{-#[], #[]})} ] &


Note: I added the factor of 1.2 as a way to give the plot a little more room. It can be anything nonzero (including the likely more-desirable 1).

## 1 Answer

You can try extracting the PlotRange using AbsoluteOptions. You need to use AbsoluteOptions, not simply Options, to make sure All gets translated to a numerical value.

g = Plot[Sin[x]^2, {x, 0, Pi}, PlotRange -> All]

max = Max@Abs@Last[PlotRange /. AbsoluteOptions[g, PlotRange]]

Show[g, PlotRange -> {All, 1.1 {-max, max}}]

• Nice, thank you Szabolcs. I wrote a little function based on your answer that I'll put in my question. – Rico Picone Jun 30 '14 at 20:11