5
$\begingroup$

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

$\endgroup$
0

2 Answers 2

6
$\begingroup$

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

PolarPlot[
 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

$\endgroup$
2
  • $\begingroup$ Is it possible to change the background color as well? $\endgroup$
    – Pedja
    Aug 3, 2019 at 12:00
  • $\begingroup$ @PeđaTerzić Have you looked up the Background option to Graphics? Just add it. $\endgroup$
    – Michael E2
    Aug 3, 2019 at 13:04
3
$\begingroup$
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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.