0
$\begingroup$

I want to do a 3D plot of this functiony[x_, r_] = -Tan[r] x where I get a set of lines evenly distributed on the r axis, with a discrete distribution. This is what I've come up for the 2D plot :

h[n_] = -Tan[n] t  
a = Map[h, Range[1.4, 1.57, 0.01]]
Plot[a, {t, -2, 0}, PlotRange -> {0, 5}]

Now I would like every line in this plot to have a value for the r axis, evenly distributed.

Any ideas how to do this?

$\endgroup$
  • $\begingroup$ What do you mean by the $r$ axis? Do you have an image of something similar to what you are trying to achieve? Would anything like this work: Show[RevolutionPlot3D[#, {t, 0, 2}] & /@ (Tan@ Range[1.4, 1.57, 0.01] t)]? $\endgroup$ – MarcoB Jun 30 at 16:05
1
$\begingroup$
Clear["Global`*"]

y[x_, r_] := -Tan[r]*x;

{rmin, rmax} = {1.4, 1.57};

ymax = 60;

Using graphics primitives with Graphics3D

gr = Graphics3D[{Thick,
   {ColorData["Rainbow"][(#[[1, 2]] - rmin)/(rmax - rmin)], Line[#]} & /@
    Table[{x, r, y[x, r]}, {r, rmin, rmax, 0.01}, {x, -2, 0, 0.05}]},
  BoxRatios -> {1, 1, 1/2},
  Axes -> True,
  PlotRange -> {Automatic, Automatic, {0, ymax}},
  AxesLabel -> (Style[#, 14, Bold] & /@ {x, r, y})]

enter image description here

Overlaying the curves on Plot3D

Show[
 Plot3D[y[x, r], {x, -2, 0}, {r, 1.4, 1.57},
  ClippingStyle -> None,
  PlotStyle -> Opacity[0.5],
  Mesh -> None],
 gr,
 PlotRange -> {0, ymax},
 AxesLabel -> (Style[#, 14, Bold] & /@ {x, r, y})]

enter image description here

Alternatively, using Mesh for the curves

Plot3D[y[x, r], {x, -2, 0}, {r, 1.4, 1.57},
 ClippingStyle -> None,
 PlotStyle -> Opacity[0.5],
 Mesh -> {0, 16, 0},
 MeshStyle -> Directive[Red, Thick],
 PlotPoints -> 25,
 MaxRecursion -> 2,
 AxesLabel -> (Style[#, 14, Bold] & /@ {x, r, y})]

enter image description here

| improve this answer | |
$\endgroup$

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