I was working on my solution and then I saw bobthechemist's answer, which is much better than mine. However, if you insist on using LogPlot
(and not ListLogPlot
) for your original plot, here's what I would do to transpose it:
1) Note that if you evaluate gammaPlot = LogPlot[Abs[Gamma[x]], {x, -5, 2}];
gammaPlot // InputForm
, the internal representation of your gammaPlot
curve are the pairs of points within the Line
function. In fact, there are 4 separate Line
's in the curve as it breaks at x = -2, x = -1, and x= 0 (not sure why the curve doesn't break at the other negative integer values).
2) To extract these points, I use Cases
with a transformation rule involving Reverse
to switch the x and y plot points. You can just use Line[points_]
to pick out the pattern since all the points are nested within a huge list anyway, but I decided to hash out the pattern structure in more detail to illustrate the use of Map
.
Cases[gammaPlot,
Line[points : {{_, _} ..}] :> Reverse /@ points, Infinity]
3) Since Log (natural log) was applied to the y values to produce the y plot points of the LogPlot
, I use Exp[y]
in a transformation rule to restore the y-values (which are now the horizontal/x values). I then used ListLogLinearPlot
(with the Joined -> True
option to connect the points) to display the final curve. As you can see the 4 Line
sections are reproduced.
ListLogLinearPlot[% /. {y_, x_} :> {Exp[y], x}, Joined -> True]

Sidenote: to make the plot one color, just apply Join
to combine the Line
's together. Warning: doing so might artificially connect any discontinuities in your plot. Therefore, I'd recommend leaving Join
out and instead specify the overall look of your plot using PlotStyle
at the end.
ListLogLinearPlot[
Join @@ Cases[gammaPlot,
Line[points : {{_, _} ..}] :> Reverse /@ points, Infinity] /. {y_,
x_} :> {Exp[y], x}, Joined -> True]

One-step solution to plot the inverse of a LogPlot
curve on a ListLogLinearPlot
Clear[inverseLogPlot]
inverseLogPlot[f_, {xp_, xmin_?NumericQ, xmax_?NumericQ},
options___] :=
With[{originalPlot = LogPlot[f, {xp, xmin, xmax}]},
ListLogLinearPlot[
Cases[originalPlot,
Line[points : {{_, _} ..}] :> Reverse /@ points,
Infinity] /. {y_, x_} :> {Exp[y], x}, Joined -> True, options]]
inverseLogPlot[Abs[Gamma[x]], {x, -5, 2}, Frame -> True,
PlotStyle -> Red]

Comparison with bobthechemist's method
Bob's method is much more comprehensible and intuitive than my method, so I would suggest you to use that method if you need to plot something quick. However, one advantage of my method--and please let me know if I'm mistaken--is that it uses the adaptive sampling of MMA when it plots a function (ref):

This could be seen by comparing my transposed plot to that of Bob. The peaks of my plot go much higher than Bob's to reflect the fact that f[x] goes to infinity at negative integer values of x.
Clear[bobLogPlot]
bobLogPlot[f_, {xp_, xmin_?NumericQ, xmax_?NumericQ}, options___] :=
ListLogLinearPlot[Table[{f, xp}, {xp, xmin, xmax, 0.01}],
Joined -> True, options]
TableForm[{LogPlot[#, {x, -5, 2}, Frame -> True],
inverseLogPlot[#, {x, -5, 2}, Frame -> True],
ListLogPlot[Table[{x, #}, {x, -5, 2, 0.01}], Joined -> True,
Frame -> True],
bobLogPlot[#, {x, -5, 2}, Frame -> True]} &@Abs[Gamma[x]],
TableHeadings -> {{"LogPlot", "inverseLogPlot (transposed)",
"ListLogPlot", "bobLogPlot (transposed)"}}]

Edit: this plot should show how LogPlot
is sampled differently from ListLogPlot
. Please delete if unnecessary.
Show[
LogPlot[Abs[Gamma[x]], {x, -5, 2},
PlotLegends ->
Style["LogPlot[Abs[Gamma[x]],{x,-5,2}]", Red]~Placed~Above,
PlotStyle -> None, Mesh -> All,
MeshStyle -> Directive[Red, AbsolutePointSize[0.7]]],
ListLogPlot[Table[{x, Abs[Gamma[x]]}, {x, -5, 2, 0.01}],
PlotLegends ->
Style["ListLogPlot[Table[{x,Abs[Gamma[x]]},{x,-5,2,0.01}]]", Blue]~
Placed~Below,
PlotStyle -> Directive[Blue, AbsolutePointSize[0.7]]]]
