1

I'm studying the following short code in an answer:

dphi = Pi/30; (* angle *)
rend = 0.99; (* radius *)
pts = Table[
  r*Exp[I N[phi, 30]], {phi, -Pi + dphi/2, Pi - dphi/2, dphi},
 {r, 0, rend, rend/10}]; (* a table of points in the polar coordinate grid*)

toColor[z_] := List @@ ColorConvert[Hue[Arg[N[z]]/(2 Pi)], "RGB"] 
(* generate colors *)

line[pts_] := line[pts, Identity]; (* define a function using the next one*)

line[pts_, func_] := Line[ReIm[func[pts]], VertexColors -> (toColor /@ pts)]
Graphics[{line /@ pts, line /@ Transpose[pts]}]

I can trace line by line to see how the functions Line[] and Graphics[] work. It looks not very natural and very smart to me.

Can this be translated to a version using ParametricPlot instead?

  • 1
    ParametricPlot[] does not have the ability to color mesh lines with a function instead of a solid color. If you're willing to sacrifice that, then yes, this is doable with ParametricPlot[]. – J. M.'s missing motivation Sep 19 '17 at 00:22
  • 1
    If you really want to use ParametricPlot[], you need to do some work: Show[Table[ParametricPlot[ReIm[r Exp[I t]], {r, 0, rend}, ColorFunction -> Function[{x, y}, Hue[Arg[x + I y]/(2 Pi)]], ColorFunctionScaling -> False], {t, -Pi + dphi/2, Pi - dphi/2, dphi}], Table[ParametricPlot[ReIm[r Exp[I t]], {t, -Pi + dphi/2, Pi - dphi/2}, ColorFunction -> Function[{x, y}, Hue[Arg[x + I y]/(2 Pi)]], ColorFunctionScaling -> False], {r, 0, rend, rend/10}], Axes -> None, PlotRange -> All] – J. M.'s missing motivation Sep 19 '17 at 00:30
  • @J.M. many thanks. –  Sep 19 '17 at 00:40
  • @J.M.: So does your second comment contradict the first one? (Your code works well.) –  Sep 19 '17 at 01:37
  • 1
    The code in the second one is a hack; that is, I generate curves individually and use Show[] to bring them all together at the end. So, the two comments are definitely consistent. It's not doable with a single convenient ParametricPlot[], but you can do it with a little work. – J. M.'s missing motivation Sep 19 '17 at 05:22

1 Answers1

2

Thanks to @J.M.'s comment, I learned that ParametricPlot alone would not work. One can however do the following:

dphi = Pi/30; rend = 0.99; pts = 
 Table[r*Exp[I N[phi, 30]], {phi, -Pi + dphi/2, Pi - dphi/2, 
   dphi}, {r, 0, rend, rend/10}];
Show[
 Table[ParametricPlot[ReIm[r Exp[I t]], {r, 0, rend}, 
   ColorFunction -> Function[{x, y}, Hue[Arg[x + I y]/(2 Pi)]], 
   ColorFunctionScaling -> False], {t, -Pi + dphi/2, Pi - dphi/2, 
   dphi}], Table[
  ParametricPlot[ReIm[r Exp[I t]], {t, -Pi + dphi/2, Pi - dphi/2}, 
   ColorFunction -> Function[{x, y}, Hue[Arg[x + I y]/(2 Pi)]], 
   ColorFunctionScaling -> False], {r, 0, rend, rend/10}], 
 Axes -> None, PlotRange -> All]

enter image description here