Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plotting on the y-axis in Mathematica

I have another question about Wolfram Mathematica. Is there someone that knows how I can plot a graphic on the y axis?

I hope that the figure helps.

enter image description here

like image 214
BlackShadow Avatar asked Jun 01 '11 16:06

BlackShadow


People also ask

What is plot range in Mathematica?

PlotRange (Built-in Mathematica Symbol) PlotRange is an option for graphics functions that specifies what range of coordinates to include in a plot. Options for Graphics (Mathematica Tutorial) When Mathematica plots a graph for you, it has to make many choices.

Can you graph in Wolfram Alpha?

Plotting functions in the Cartesian plane is such a simple task with Wolfram|Alpha: just enter the function you are looking to graph, and within seconds you will have a beautiful result.


2 Answers

ParametricPlot[{5 Sin[y], y}, {y, -2 \[Pi], 2 \[Pi]}, 
                Frame -> True,  AxesLabel -> {"x", "y"}]

enter image description here


EDIT

None of the answers given thus far can work with Plot's Filling option. Plot's output contains a GraphicsComplex in that case (which, incidentally, breaks Mr.Wizard's replacements). To get the filling capability (it doesn't work for a standard plot without filling) you could use the following:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Filling -> Axis] /.  List[x_, y_] -> List[y, x]

enter image description here

Plot[{Sin[x], .5 Sin[2 x]}, {x, 0, 2 \[Pi]}, Filling -> {1 -> {2}}] 
   /. List[x_, y_] -> List[y, x]

enter image description here

like image 197
Sjoerd C. de Vries Avatar answered Sep 19 '22 20:09

Sjoerd C. de Vries


You can flip the axes after plotting with Reverse:

g = Plot[Sin[x], {x, 0, 9}];

Show[g /. x_Line :> Reverse[x, 3], PlotRange -> Automatic]

enter image description here

With a minor change this works for plots using Filling as well:

g1 = Plot[{Sin[x], .5 Sin[2 x]}, {x, 0, 2 \[Pi]}];
g2 = Plot[{Sin[x], .5 Sin[2 x]}, {x, 0, 2 \[Pi]}, Filling -> {1 -> {2}}];

Show[# /. x_Line | x_GraphicsComplex :> x~Reverse~3,
     PlotRange -> Automatic] & /@ {g1, g2}

enter image description here

(It may be more robust to replace the RHS of :> with MapAt[#~Reverse~2 &, x, 1])


As a Function

Here is the form I recommend one use. It includes flipping of the original PlotRange rather than forcing PlotRange -> All:

axisFlip = # /. {
   x_Line | x_GraphicsComplex :> 
      MapAt[#~Reverse~2 &, x, 1], 
   x : (PlotRange -> _) :>
      x~Reverse~2 } &;

To be used like: axisFlip @ g1 or axisFlip @ {g1, g2}


A different effect can be had with Rotate:

Show[g /. x_Line :> Rotate[x, Pi/2, {0,0}], PlotRange -> Automatic]

enter image description here

like image 26
Mr.Wizard Avatar answered Sep 19 '22 20:09

Mr.Wizard