This question is related to this answer.

What should I change in the following code to replace black color with blue color in the second image?

PolarPlot[Evaluate @ Table[n + ChebyshevT[n, t/Pi - 1], {n, 0, 40, 2}], {t, 0, 2 Pi}]
Graphics @ FilledCurve @ Cases[%, _Line, -1]

enter image description here

enter image description here


Put the styling directives before the graphics taken from the plot:

 Evaluate@Table[n + ChebyshevT[n, t/Pi - 1], {n, 0, 40, 2}],
 {t, 0, 2 Pi}];
Graphics[{Blue, FilledCurve@Cases[%, _Line, -1]}]

enter image description here

  • $\begingroup$ Is it possible to change the background color as well? $\endgroup$ – Peđa Terzić Aug 3 at 12:00
  • $\begingroup$ @PeđaTerzić Have you looked up the Background option to Graphics? Just add it. $\endgroup$ – Michael E2 Aug 3 at 13:04
plrplt = PolarPlot[Evaluate@Table[n + ChebyshevT[n, t/Pi - 1], {n, 0, 40, 2}], {t, 0, 2 π}];

To get different colors between layers you can sort the lines by the area of minimal bounding disk and replace Lines with Polygons:

sorted = SortBy[-Area[BoundingRegion[#, "MinDisk"]] &] @ Cases[plrplt, Line[x_] :> x, All];

colors = { Yellow, Red, White, Blue};

Graphics[{First[colors = RotateLeft@colors], Polygon @ #} & /@ sorted]

enter image description here

An alternative way to get the same picture is to partition sorted lines and use FilledCurve for each pair:

Graphics[{First[colors=RotateLeft@colors], FilledCurve[Line/@#]}&/@ Partition[sorted, 2, 1]]

same picture


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.