I apologize if this is a obvious question and answer, I don't often use Mathematica to display plots or graphics in general to be honest. So, I was tutoring my cousin yesterday in relation to Polar functions and decided to bring up Mathematica to illustrate some of the ideas we were discussing. I quickly typed a one line command into Mathematica 8 and got an odd result. When rendering a polar function, Mathematica took a few seconds to make it smooth. Prior to this it has too many lines (see picture, before is on left and after is on the right.)
The code is:
Manipulate[PolarPlot[Sin[nS*t], {t, -5 Pi, 5 Pi}], {nS, 1, 20, 1}]

Does anyone know why this is happening and if there is a way to make Mathematica render smooth at first?
Answer
This is done intentionally to update the plot quickly as you move the slider. Manipulate changes the setting for PerformanceGoal (via $PerformanceGoal) to "Speed" while you move the slider, then to "Quality" after you let go. This is seen in this simple demonstration:
Manipulate[{n, $PerformanceGoal}, {n, 0, 1}]
If you want the final quality while dragging at the expense of update speed you can give an explicit PerformanceGoal -> "Quality":
Manipulate[
PolarPlot[Sin[nS*t], {t, -5 π, 5 π},
PerformanceGoal -> "Quality"], {nS, 1, 20, 1}]
Alternatively you can take manual control of this process with ControlActive, and specify the PlotPoints that are used while dragging and after release:
Manipulate[
PolarPlot[Sin[nS*t], {t, -5 π, 5 π},
PlotPoints -> ControlActive[50, 150]], {nS, 1, 20, 1}]
You can turn off updating while dragging altogether using ContinuousAction:
Manipulate[PolarPlot[Sin[nS*t], {t, -5 π, 5 π}],
{nS, 1, 20, 1}, ContinuousAction -> False]
As belisarius comments you range for t is excessive: {t, -π, π} will not run multiple circuits. This will allow the plot to update much more quickly. I leave the original value in the examples above so that the effect is easier to observe.
Comments
Post a Comment