2
$\begingroup$

how can i exchange x and y Axis of this loglogplot?

x1[y_] := y+3
x2[y_] := y-1

myplot = LogLogPlot[{x1[y], x2[y]}, {y, 10^-4, 100}, PlotRange -> Full, 
  PlotPoints -> 10, PlotLegends -> "Expressions", ImageSize -> 600, 
  AspectRatio -> Full, Filling -> None]

this is a simple example, my real functions of X are very complicated and i can not find Y with explicit function of x.

  1. Is there any way to switch the axis of this LogLogPlot?

  2. How can I export this plot data point in a matrix?

$\endgroup$
3
  • $\begingroup$ Why is the LogLog part relevant? $\endgroup$ Jul 24, 2015 at 18:26
  • 1
    $\begingroup$ Its relevant because there is no ParametricLogLogPlot.. $\endgroup$
    – george2079
    Jul 24, 2015 at 19:01
  • $\begingroup$ related: mathematica.stackexchange.com/a/18669/2079. Note axisFlip does not work correctly however, but may be a start $\endgroup$
    – george2079
    Jul 24, 2015 at 19:11

2 Answers 2

4
$\begingroup$

This works for your example:

 y1 = InverseFunction[FunctionInterpolation[x1[y], {y, 10^-4, 100}]]
 y2 = InverseFunction[FunctionInterpolation[x2[y], {y, 10^-4, 100}]]
 LogLogPlot[{y1[x],y2[x]}, {x, 10^-3, 100}]

However I'm afraid FunctionInterpolation might not do a good job of sampling depending on your function.

You can do this:

 y1 = InverseFunction[x1]
 y2 = InverseFunction[x2]
 LogLogPlot[{y2[x], y1[x]}, {x, 10^-3, 100}]

But it might be painfully slow as it effectively iterates to find every plot point.

Here is a bit of a hack to fix the axes after using axisFlip: (LogLogPlot does something weird with PlotRange so you can't simply transpose the range as axisFlip does )

(https://mathematica.stackexchange.com/a/18669/2079)

Show[LogLogPlot[ Null, {x, 3, 100},
   PlotRange -> {{10^-3, 100}, {10^-4, 100}}], myplot // axisFlip]

enter image description here

$\endgroup$
4
  • $\begingroup$ i couldn't use of axisFlip, the error is: "Could not combine the graphics objects in Show" $\endgroup$
    – Alex
    Jul 24, 2015 at 19:27
  • $\begingroup$ you need to copy and evaluate the definition of axisFlip from the linked answer. $\endgroup$
    – george2079
    Jul 24, 2015 at 19:32
  • $\begingroup$ Wow, It works! you are lifesaving! $\endgroup$
    – Alex
    Jul 24, 2015 at 19:41
  • $\begingroup$ @george209 Very nice! Could you elaborate on the "hack" required for LogLogPlot. It looks like maybe you are plotting nothing (Null) but setting the Axis needed for the flipped plot. Would you have to do something like this for LogPlot and LogLinearPlot as well? $\endgroup$ Jul 25, 2015 at 2:01
4
$\begingroup$

Use ListLogLogPlot with a list of values for from your functions.

points = Transpose[{{x1[#], #}, {x2[#], #}} & /@ Range[10^-4, 100, (100 - 10^-4)/200]];

ListLogLogPlot[points, Joined -> True]

enter image description here

I've used 200 plot points to get a nice smooth plot.

Hope this helps.

$\endgroup$
1
  • $\begingroup$ Thanks a lot, but it is not work correctly for my complicated X functions. $\endgroup$
    – Alex
    Jul 27, 2015 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.