Re: Plotting a straight line in a 3D plot
- To: mathgroup at smc.vnet.net
- Subject: [mg81050] Re: Plotting a straight line in a 3D plot
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sun, 9 Sep 2007 06:15:56 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fbqq6f$727$1@smc.vnet.net>
kheimon wrote:
> Is there any way, in Mathematica, I can plot a straight line in a 3D
> plot environment?
>
> For example: Plot3D[{{y = 1 - x, z = y - 1}}, {x, -5, 5}, {y, -5, 5}]
>
> plots two surfaces, not their intersection (which is a straight line).
First, the given example will work better if written as follows (the
assignments = have been removed as well as the extra curly brackets),
Plot3D[{1 - x, y - 1}, {x, -5, 5}, {y, -5, 5}]
Second, to plot a line in 3D, one can use *Graphics3D* and *Line* as in
Graphics3D[Line[{{0, 0, 0}, {1, 1, 1}}]]
and one can combine a regular plot with a line with *Show*
Show[Plot3D[{1 - x, y - 1}, {x, -5, 5}, {y, -5, 5}],
Graphics3D[Line[{{0, 0, 0}, {0, 5, 5}}]]]
HTH,
--
Jean-Marc