# How can I replace Polygon by Line in the output of ParametricPlot3D while preserving colours?

{m0, m1, m2, m3, m4, m5, m6, m7} = {4, 3, 2, 3, 6, 2, 6, 4};
r = Sin[m0*phi]^m1 + Cos[m2*phi]^m3 + Sin[m4*theta]^m5 + Cos[m6*theta]^m7;
g = ParametricPlot3D[{r*Sin[phi]*Cos[theta], r*Cos[phi],
r*Sin[phi]*Sin[theta]}, {phi, 0, Pi}, {theta, 0, 2 Pi},
ColorFunction -> (Blend[{Red, Yellow, Green, Cyan, Blue}, #] &),
Mesh -> None, Boxed -> False, Axes -> 0];
g /. Polygon -> Line


gives this:

The colour information is gone.

I want to get the output below:

How can I get it?

-
How did you get the second graphic? – Szabolcs Mar 10 '13 at 17:38
@Szabolcs, I get the second graphics from python's lib enthought.mayavi. hyry.dip.jp:8000/pydoc/mlab_and_mayavi.html – chyaong Mar 10 '13 at 17:43

## 1 Answer

Use

Normal[g] /. Polygon -> Line


Polygon colours are usually specified using the VertexColors option. This works both in Polygon and in Line, so the colour should be preserved when you do a simple replace operation. But ParametricPlot3D will produce a GraphicsComplex and will place the VertexColor option inside GraphicsComplex instead of Polygon.

Normal will simply get rid of the GraphicsComplex.

-