6
$\begingroup$

I have the 3D plot here. Is there any way to color or to shade the curve's surface?

b = Table[ParametricPlot3D[{i, y, -y^2 + 2}, {y, -4, 4}], {i, 1, 8}];
Show[b, PlotRange -> {{0, 10}, {-4, 4}, {0, 3}}]

I have try to use FaceForm but it didn't work.

$\endgroup$
  • 1
    $\begingroup$ The code produces eight 2D curves. Is that what you had in mind? If so, do you want each curve to have a separate color, or to shade each of the eight curves with varying color? $\endgroup$ – bbgodfrey Nov 23 '16 at 2:29
  • $\begingroup$ Yes, it creates 8 curves and I want to shade the "space" between the curves so that it looks like a surface. $\endgroup$ – ssa Nov 23 '16 at 2:35
11
$\begingroup$

Perhaps, this is what you had in mind.

ParametricPlot3D[{i, y, -y^2 + 2}, {y, -4, 4}, {i, 1, 8}, 
    ColorFunction -> Function[{x, y, z}, Hue[x]], PlotRange -> {{0, 10}, {-4, 4}, {0, 3}}]

enter image description here

The code in the question instead produces eight 2D curves. With similar coloring, they look like

b = Table[ParametricPlot3D[{i, y, -y^2 + 2}, {y, -4, 4}, 
    PlotStyle -> Hue[(i - 1)/7]], {i, 1, 8}]; 
Show[b, PlotRange -> {{0, 10}, {-4, 4}, {0, 3}}]

enter image description here

Addendum

If uniform colors are desired between each curve, then use

a = ParametricPlot3D[{i, y, -y^2 + 2}, {y, -4, 4}, {i, 1, 8}, 
    ColorFunction -> Function[{x, y, z}, Hue[Round[x - 1 - 1/14, 1/7]]], 
    PlotRange -> {{0, 10}, {-4, 4}, {0, 3}}, Mesh -> None, PlotPoints -> 50];
b = Table[ParametricPlot3D[{i, y, -y^2 + 2}, {y, -4, 4}, PlotStyle -> Black], {i, 1, 8}];
Show[a, b]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Great! Thank you. $\endgroup$ – ssa Nov 23 '16 at 2:59
5
$\begingroup$

Just to illustrate use of MeshShading. Using Bob Hanlon's function:

f = Hue[Round[(# - 1)/7, 1/7]] &;
ParametricPlot3D[{i, y, -y^2 + 2}, {y, -4, 4}, {i, 1, 8}, 
 PlotRange -> {{0, 10}, {-4, 4}, {0, 3}}, MeshFunctions -> (#1 &), 
 Mesh -> {Range[2, 7]}, MeshShading -> (f /@ Range[7]), 
 MeshStyle -> Thickness[0.005], BoundaryStyle -> Thickness[0.005]]

enter image description here

| improve this answer | |
$\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.