2
$\begingroup$

enter image description here

I have a data including the function theta as a function of x ranging from 0 to pi and the function theta ranges from -pi to pi or from 0 to 2pi:

I would like to plot this function something like winding number as the figure attached. How can I plot this type of function using Mathematica?

Regards.

$\endgroup$
  • 1
    $\begingroup$ You can include any code you have written so far. $\endgroup$ – Sektor Mar 16 '16 at 9:43
  • 1
    $\begingroup$ Possible duplicate of Phase portrait on a cylinder $\endgroup$ – Kuba Mar 16 '16 at 9:44
  • 1
    $\begingroup$ @Kuba I'm not sure. This one isn't asking for an arbitrarily complicated graph projected onto a cylinder, but simply a polar plot extended along the third dimensions which allows for somewhat simpler solutions. $\endgroup$ – Martin Ender Mar 16 '16 at 9:51
  • $\begingroup$ @MartinBüttner Right, vote retracted. $\endgroup$ – Kuba Mar 16 '16 at 9:54
  • 1
    $\begingroup$ closely related: Spherical parametric plot $\endgroup$ – Kuba Mar 16 '16 at 10:16
6
$\begingroup$

You can write a very simple elongated polar plot using ParametricPlot3D and cylindrical coordinates:

f[x_] := x^2
Show[
  Graphics3D[{Opacity[0.8], Glow@White, Cylinder[{{0, 0, 0}, {Pi, 0, 0}}, 1]},
     Axes -> True, Boxed -> False], 
  ParametricPlot3D[{x, -Cos[t], -Sin[t]} /. t -> f[x], {x, 0, Pi}]
]

enter image description here

I suppose the presentation could be improved a bit by also rendering the top and bottom "edge" of the cylinder and using an orthogonal instead of perspective projection, but this gets you your graph on the cylinder.

You can also avoid the manual conversion from cylindrical to Cartesian coordinates by using

Evaluate @ CoordinateTransform["Cylindrical" -> "Cartesian", {1, f[x], x}]

inside the ParametricPlot3D, which probably makes for clearer code. But note that in this case the roles of the x and z axes are swapped, so you'll want to change the orientation of the Cylinder as well:

Cylinder[{{0, 0, 0}, {0, 0, Pi}}, 1]
$\endgroup$
  • $\begingroup$ I have another question. I want to replace the weak-lightening solid line with the dashed lines when lines on the cylinder enter into the backside of cylinder. How can I achieve it? $\endgroup$ – Lee Apr 12 '16 at 20:07
  • $\begingroup$ @Lee Like this? Otherwise please ask a new question. $\endgroup$ – Martin Ender Apr 12 '16 at 20:10
  • $\begingroup$ Thanks! Although it looks much complicated, I will try it! $\endgroup$ – Lee Apr 12 '16 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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