Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 3
    $\begingroup$ Surprising (your use of Dynamic), innovative and upvoteable :) $\endgroup$ Commented Oct 10, 2014 at 18:15
  • $\begingroup$ Could you please explain why this approach works? I'm surprised. +1, of course. $\endgroup$ Commented Oct 10, 2014 at 18:59
  • $\begingroup$ @Alexey, i wish i knew why:) my vague hunch is that the FrontEnd -- as the owner/manager of Dynamic stuff -- triggers new calls to RandomReal/RandomColor since a given call changes something visible ..? Thanks for the vote by the way. $\endgroup$ Commented Oct 10, 2014 at 19:05
  • 1
    $\begingroup$ The InputForm of the output shows that every Polygon has the color specification Dynamic[Hue[RandomReal[]]. It means that the actual reason is inside the Kernel: it keeps the Dynamic head as the head for every color specification it produces from MeshShading. Very interesting and undocumented design decision! Does other plotting functions behave in the same way or only ParametricPlot? A documented way to get the same result is MeshShading->{{Dynamic@Hue@RandomReal[],Dynamic@Hue@RandomReal[]},{Dynamic@Hue@RandomReal[],Dynamic@Hue@RandomReal[]}}. $\endgroup$ Commented Oct 10, 2014 at 19:27
  • 1
    $\begingroup$ We can also get the same result without Dynamic in the output: ParametricPlot[r {Cos[t],Sin[t]},{r,0,12},{t,0,2Pi},Mesh->23,Axes->False,MeshShading->Dynamic@{{Hue@RandomReal[],Hue@RandomReal[]},{Hue@RandomReal[],Hue@RandomReal[]}},PlotRange->{{-9,9},{-4,4}}]/.Dynamic->Identity. $\endgroup$ Commented Oct 10, 2014 at 19:55