# point-wise transform of Plot

Suppose I have the following plot:

Plot[(1 - p2)^2/(p2^2 + (1 - p2)^2), {p2, 0, 1}, AxesLabel -> {"p2", "p1"}]


Now I want to do a point-wise transform to every point $(p2,p1)$ on the line (making a new plot) using:

$p1 \rightarrow \dfrac{p1-\gamma}{1-\gamma}\quad p2\rightarrow\dfrac{p2-\gamma}{1-\gamma}$

In other words, I want to move every point on the line $(p2,p1)$ to a new location $\left(\dfrac{p2-\gamma}{1-\gamma},\dfrac{p1-\gamma}{1-\gamma}\right)$.

How should I achieve that?

• I suppose it is unclear here whether you want to maintain the relationship p2[p1] as defined in your original plot. Should p2 become (p2[p1] - gamma)/(1- gamma) -or- (p2[(p1-gamma)/(1-gamma)] - gamma)/(1- gamma) ? Commented Jun 6, 2013 at 14:37
• @CoreyKelly, no, I don't need that
– wdg
Commented Jun 6, 2013 at 15:17

If you did want to transform the plot, you can use something like:

Manipulate[
Plot[(1 - p2)^2/(p2^2 + (1 - p2)^2), {p2, 0, 1},
AxesLabel -> {"p2", "p1"}, PlotRange -> {-1, 1}] /.
Line[a__] :> Line @ Map[{(#[[1]] - γ)/(1 - γ), (#[[2]] - γ)/(1 - γ)} &, a],
{γ, -1, 0.5}]


which transforms the points that define the Line.

• Since the relevant functions are Listable, I'd do (# - γ)/(1 - γ) & myself... for that matter, why not Line[(a - γ)/(1 - γ)]? Commented Jun 6, 2013 at 15:02

You probably want to transform the function, not the plot:

f[p2_] := (1 - p2)^2/(p2^2 + (1 - p2)^2)
Plot[f[p2], {p2, 0, 1}, AxesLabel -> {"p2", "p1"}]
t[p2_, g_] := (f[(p2 - g)/(1 - g)] - g)/(1 - g)
Manipulate[Plot[t[p2, g], {p2, 0, 1}, AxesLabel -> {"p2", "p1"}], {g, 0, 0.999}]


I'd say this is the sort of thing LinearFractionalTransform[] was designed for:

With[{γ = 2/3},
MapAt[GeometricTransformation[#,
LinearFractionalTransform[{IdentityMatrix[2], {-γ, -γ}, {0, 0}, 1 - γ}]] &,
Plot[(1 - p2)^2/(p2^2 + (1 - p2)^2), {p2, 0, 1}, AxesLabel -> {"p2", "p1"},
PlotRange -> All], 1]]


Of course, you can use ParametricPlot[] instead of Plot[]:

With[{γ = 2/3},
ParametricPlot[LinearFractionalTransform[{IdentityMatrix[2], {-γ, -γ}, {0, 0}, 1 - γ}] @
{p2, (1 - p2)^2/(p2^2 + (1 - p2)^2)}, {p2, 0, 1},
AspectRatio -> 1/GoldenRatio, AxesLabel -> {"p2", "p1"}]]

• The primary advantage, of course, is you don't have to fiddle with the PlotRange. +1 Commented Jun 6, 2013 at 14:58
• (I know I could have done the transformation with a judicious combination of translation and scaling, but this seemed more compact.) Commented Jun 6, 2013 at 15:03
• Why do you need the With in this case? It seems to work fine without it. Commented Jun 6, 2013 at 16:44
• @Jonathan, I certainly could have made the global assignment γ = 2/3 in before executing the plots, but I prefer not to litter the Global  context if I can help it. Besides, this is the sort of thing With[]` is intended for: parameter setting. Commented Jun 6, 2013 at 16:47
• Thanks @J. M., very reasonable. Commented Jun 6, 2013 at 16:49