5
$\begingroup$

The best approach I can find is the following:

ClearAll[color];
color[a_,b_]:=Piecewise[{{Hue[1/2-Arg[a+b I]/(2\[Pi]),1,1],0.8<Norm[{a,b}]<1.0},{White,True}}];
Graphics[Flatten[Table[{color[a,b],Rectangle[{a,b},{a+0.05,b+0.05}]},{a,-1,1,0.05},{b,-1,1,0.05}]]]

color wheel graphics

This approach is very inefficient if I use enough rectangles to make the circles look smooth. It seems there must be a better way using ParametricPlot, RegionPlot, ComplexPlot, ColorFunction, etc. Can you find a better way?

$\endgroup$
1

2 Answers 2

10
$\begingroup$

Consider, for instance:

RegionPlot[
 Element[{x, y}, Annulus[{0, 0}, {0.8, 1}]], {x, -1, 1}, {y, -1, 1},
 Frame -> False, BoundaryStyle -> None, 
 ColorFunctionScaling -> False,
 ColorFunction -> (Hue[1/2 - Arg[#1 + #2 I]/(2 Pi)] &)]

enter image description here

Without ColorFunctionScaling -> False x and y are scaled to $[0, 1]$... which can be a bit surprising if you don't remember this functionality. :)

As a side note, ComplexPlot can do the same, but interestingly enough RegionFunction doesn't really work particularly well with it.


EDIT:

Inspired by @Syed, you can also accomplish the same with the following:

ComplexRegionPlot[0.8 < Abs[z] < 1, {z, 1},
 Frame -> False, BoundaryStyle -> None,
 ColorFunction -> (Hue[-#4] &)]

It is, by the way, the same as this:

ComplexRegionPlot[0.8 < Abs[z] < 1, {z, 1},
 Frame -> False, BoundaryStyle -> None,
 ColorFunctionScaling -> False,
 ColorFunction -> (Hue[1/2 - #4/(2 Pi)] &)]

Oftentimes I find the way colour function scaling works in Mma regarding coordinates more confusing than useful; #4 is clearly the argument of z, but with scaling it runs from $0$ to $1$ - but it's not that it would have been just divided by $2\pi$, no, it again depends on the actual plotted region...

$\endgroup$
1
  • $\begingroup$ that's very nice! $\endgroup$
    – lericr
    Jan 19, 2023 at 17:09
5
$\begingroup$
ComplexRegionPlot[0.75 < Abs[z] < 1
 , {z, -1 - I, 1 + I}
 , BoundaryStyle -> None
 , ColorFunction -> (Hue[#4] &)
 , Frame -> False
 ]

OR

DensityPlot[Arg[x + I y]
 , {x, y} ∈ Annulus[{0, 0}, {0.75, 1}]
 , Exclusions -> None
 , ColorFunction -> Hue
 , ImageSize -> 300
 , PlotPoints -> 50
 , MaxRecursion -> 3
 , Frame -> False
 ]

OR

PieChart[ConstantArray[1, 360]
 , SectorOrigin -> {{π, 1}, 3}
 , ChartStyle -> {
   EdgeForm[None]
   , (Hue[#] & /@ Range[0, 1, 1/360])}
 ]

enter image description here

$\endgroup$
5
  • $\begingroup$ Ah, ComplexRegionPlot behaves better than ComplexPlot with RegionFunction! $\endgroup$
    – kirma
    Jan 19, 2023 at 18:25
  • 1
    $\begingroup$ BTW, you can replace {z, -1 - I, 1 + I} with {z, 1}. $\endgroup$
    – kirma
    Jan 19, 2023 at 18:32
  • 1
    $\begingroup$ I saw the colors on 0 and $\pi$ and missed their circular progression. This can be fixed using: -Arg[x + I y] in the first solution, ColorFunction -> (Hue[-#4] &) as pointed out by @kirma and using SectorOrigin -> {{\[Pi], -1}, 3} in the PieChart solution. $\endgroup$
    – Syed
    Jan 19, 2023 at 19:14
  • $\begingroup$ @ Syed, Very good, but the graphic is upside down. $\endgroup$
    – Ted Ersek
    Jan 20, 2023 at 20:14
  • $\begingroup$ @TedErsek, please see above your comment for the resolution. $\endgroup$
    – Syed
    Jan 21, 2023 at 6:33

Your Answer

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

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