MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Switching x and y axes in a plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41525] Re: Switching x and y axes in a plot
  • From: Bill Rowe <listuser at earthlink.net>
  • Date: Sat, 24 May 2003 01:05:57 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 5/23/03 at 3:29 AM, gregory.lypny at videotron.ca (Gregory Lypny)
wrote:

>I've used Plot to graph a parabola as follows: Plot[ax^2 - 2bx + c,
>{x, xMin, xMax}].  Is there any way to plot the function so that y
>appears on the horizontal axis and x on the vertical?  (I realize the
>parabola part is uninteresting; it's actually the solution to a
>standard problem in financial economics involving the minimization of
>investment portfolio risk for a given expected return.)

There are a number of different ways in which this can be done. I'll give you two fairly simple ways

First, you can use ParametricPlot

For example, try ParametricPlot[{t^2, t}, {t, -1, 1}]

Second, there is a function in the package Graphics`Graphics` that will do this called SkewGraphics. The arguments to SkewGraphics are the graphic to be transformed and a rotation matrix. So, for your specific example, try

<<Graphics`Graphics`
Show[SkewGraphics[Plot[x^2, {x, -1, 1}, DisplayFunction->Identity],{{0, 1},{1, 0}}],DisplayFunction->$DisplayFunction]

>Another plot-related question, if I may: do all plots require the
>specification of a domain as {x, xMin, xMax}?  For example, how would
>I create a scatter plot of experimental data where I have a long
>two-column list or matrix consisting of x and y observations where the
>data determine the domain and range?

To create a scatter plot of x,y pairs use ListPlot. For example,

data = Table[{n, n+Random[]},{n,20}];
ListPlot[data];


  • Prev by Date: Re: TraditionalForm output and subscript variable
  • Next by Date: Re: Switching x and y axes in a plot
  • Previous by thread: Switching x and y axes in a plot
  • Next by thread: Re: Switching x and y axes in a plot