6
$\begingroup$

This is my code:

RevolutionPlot3D[x^2, {x, 0, 1}, RevolutionAxis -> "X", 
 MeshFunctions -> {Boole[#2 == #^2] &}, Mesh -> {{1}}, 
 MeshStyle -> Directive[Red, Thickness[0.03]], PlotPoints -> 200, 
 Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, 0}, 
 AxesStyle -> {Red, Green, Blue}]

enter image description here

But if I set BoundaryStyle -> None, then all MeshStyle will disappear. So how to just keep the MeshStyle but don't get that red circle BoundaryStyle?

$\endgroup$
3
  • 1
    $\begingroup$ MeshFunctions -> {#4 &}, Mesh -> {{.99}}, BoundaryStyle -> None $\endgroup$
    – cvgmt
    Jan 2 at 11:10
  • $\begingroup$ @cvgmt I mean I don't want to get that red circle... $\endgroup$
    – yode
    Jan 2 at 11:22
  • $\begingroup$ MeshFunctions -> {#5 &}, Mesh -> {{2Pi - .001}}, BoundaryStyle -> None $\endgroup$
    – cvgmt
    Jan 2 at 11:54

2 Answers 2

5
$\begingroup$

You can hide the unwanted ring using a combination of options Exclusions, ExclusionsStyle and the Method sub-option "BoundaryOffset" -> False:

RevolutionPlot3D[x^2, {x, 0, 1},
 RevolutionAxis -> "X", 
 PlotPoints -> 100, 
 ImageSize -> 600,
 ViewPoint -> {0.75, -1.5, 3},
 Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, 0}, 
 AxesStyle -> {Red, Green, Blue}, 
 MeshFunctions -> {Boole[#^2 == #2] &}, 
 Mesh -> {{1}}, 
 MeshStyle -> Directive[Red, Thickness[0.01]],
 Method -> {"BoundaryOffset" -> False}, 
 Exclusions -> {x == 1}, 
 ExclusionsStyle -> None] /.  Line[x_] :> Tube[x, .015]

enter image description here

Alternatively, the combination of options Method -> {"BoundaryOffset" -> False}, MeshFunctions -> {#5 &}, Mesh -> {{0}} and BoundaryStyle -> None gives the same picture.

And a variation on Craig Carter's approach using ParametricPlot3D

rp = RevolutionPlot3D[x^2, {x, 0, 1},
 RevolutionAxis -> "X", 
 Mesh -> None,
 PlotPoints -> 100, 
 ImageSize -> 600,
 ViewPoint -> {0.75, -1.5, 3},
 Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, 0}, 
 AxesStyle -> {Red, Green, Blue}];

Show[rp, 
  ParametricPlot3D[{t, 0, t^2}, {t, 0, 1}, 
    PlotStyle -> Directive[Red, CapForm["Round"], Tube[.015]]]]

enter image description here

I you want to add the x==1 ring with a different style, you can add a second ParametricPlot3D to Show:

Show[rp, 
  ParametricPlot3D[{t, 0, t^2}, {t, 0, 1}, 
    PlotStyle -> Directive[Red, CapForm["Round"], Tube[.015]]], 
  ParametricPlot3D[{1, Cos @ t, Sin @ t}, {t, 0, 2 Pi}, 
    PlotStyle -> Directive[Green, CapForm["Round"], Tube[.01]]]]

enter image description here

$\endgroup$
3
  • $\begingroup$ I'm curious why I can't get rid of the circular red edge of this function using your method. RevolutionPlot3D[E^(-x^2), {x, -5, 5}, Boxed -> False, Axes -> True, AxesStyle -> {Red, Green, Blue}, AxesOrigin -> {0, 0, 0}, MeshFunctions -> {Boole[#2 == E^(-#^2)] &}, Mesh -> {{1}}, MeshStyle -> Directive[Red, Thickness[0.01]]] $\endgroup$
    – yode
    Jan 2 at 16:28
  • $\begingroup$ @yode, the second method (Method -> {"BoundaryOffset" -> False} + MeshFunctions -> {#5 &} + Mesh -> {{0}} + BoundaryStyle -> None) works for the example in your comment. I don't know how to set Exclusions for the first method to work. $\endgroup$
    – kglr
    Jan 2 at 21:36
  • $\begingroup$ @yode RevolutionPlot3D[E^(-x^2), {x, -5, 5}, Boxed -> False, Axes -> True, AxesStyle -> {Red, Green, Blue}, AxesOrigin -> {0, 0, 0}, Mesh -> None, Method -> {"BoundaryOffset" -> False}, Exclusions -> {{Abs@x == 5}}, ExclusionsStyle -> None, BoundaryStyle -> Red] $\endgroup$
    – cvgmt
    Jan 3 at 1:20
3
$\begingroup$

This is a hack, but a working hack:

rp = RevolutionPlot3D[x^2, {x, 0, 1}, RevolutionAxis -> "X", 
  PlotPoints -> 200, MeshStyle -> None, Boxed -> False, Axes -> True, 
  AxesOrigin -> {0, 0, 0}, AxesStyle -> {Red, Green, Blue}]

Show[rp, Graphics3D[
  {Red, Tube[BSplineCurve[{#, 0, #^2} & /@ Range[0, 1, .1]]],
   Blue, 
   Tube[BSplineCurve[{1, Cos[#], Sin[#]} & /@ Range[0, 2 Pi, Pi/24]]]
   }
  ]
 ]
$\endgroup$

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.