Function Repository Resource:

DLMFHue

Source Notebook

Get a color based on the Digital Library of Mathematical Functions (DLMF) color wheel

Contributed by: Jan Mangaldan

ResourceFunction["DLMFHue"][h]

is a color based on the color wheel, as modified by the Digital Library of Mathematical Functions (DLMF).

ResourceFunction["DLMFHue"][h,s,b]

specifies the saturation and brightness.

ResourceFunction["DLMFHue"][h,s,b,a]

specifies opacity a.

Details and Options

The parameters h, s, b, and a must all be between 0 and 1. Values of s, b, and a outside this range are clipped. Values of h outside this range are treated cyclically.
As h varies from 0 to 1, the color corresponding to ResourceFunction["DLMFHue"][h] runs through red, yellow, green, cyan, blue, magenta, and back to red again.
ResourceFunction["DLMFHue"][h] is equivalent to ResourceFunction["DLMFHue"][h,1,1].
The alternative forms ResourceFunction["DLMFHue"][{h,s,b}] and ResourceFunction["DLMFHue"][{h,s,b,a}] can also be used.
ResourceFunction["DLMFHue"][h,s,b,a] is equivalent to Directive[ResourceFunction["DLMFHue"][h,s,b],Opacity[a]].
If no opacity has been specified, ResourceFunction["DLMFHue"][h,s,b] is equivalent to ResourceFunction["DLMFHue"][h,s,b,1].
For more information, see DLMF-About Color Map.

Examples

Basic Examples (2) 

Specify the color of a graphic primitive:

In[1]:=
Graphics[{ResourceFunction["DLMFHue"][1/2], Disk[]}]
Out[1]=

Specify the color with opacity:

In[2]:=
Graphics3D[{ResourceFunction["DLMFHue"][1/3, 1, 1, .5], Sphere[]}]
Out[2]=

Scope (5) 

Visualize the DLMF color wheel:

In[3]:=
ParametricPlot[{r Cos[\[Theta]], r Sin[\[Theta]]}, {r, 0, 1}, {\[Theta], -\[Pi], \[Pi]}, ColorFunction -> (ResourceFunction["DLMFHue"][#4/(2 \[Pi])] &), ColorFunctionScaling -> False, {Axes -> None, BoundaryStyle -> None, Exclusions -> None, Frame -> None}]
Out[3]=

DLMFHue[h] is equivalent to DLMFHue[h,1,1]:

In[4]:=
{Graphics[{ResourceFunction["DLMFHue"][1/8], Disk[]}], Graphics[{ResourceFunction["DLMFHue"][1/8, 1, 1], Disk[]}]}
Out[4]=

DLMFHue[{h,s,b}] is equivalent to DLMFHue[h,s,b]:

In[5]:=
Map[Graphics[{ResourceFunction["DLMFHue"][#], Disk[]}] &, {{1, 1, 1}, {1/2, 1, 1}, {1/4, 1, 1}}]
Out[5]=

Use Opacity with DLMFHue:

In[6]:=
Table[Graphics[{ResourceFunction["DLMFHue"][0.08], Disk[{1, 0}], Opacity[a], ResourceFunction["DLMFHue"][1], Disk[]}], {a, 0, 1, .33}]
Out[6]=

Use the opacity argument in DLMFHue directly:

In[7]:=
Table[Graphics[{ResourceFunction["DLMFHue"][.08], Disk[{1, 0}], ResourceFunction["DLMFHue"][1, 1, 1, a], Disk[]}], {a, 0, 1, .33}]
Out[7]=

Applications (2) 

Use with ComplexPlot:

In[8]:=
ComplexPlot[(-1 + z)/(1 + z + z^2), {z, -2 - 2 I, 2 + 2 I}, ColorFunction -> (ResourceFunction["DLMFHue"][#8/(2 \[Pi])] &), ColorFunctionScaling -> False, Exclusions -> None]
Out[8]=

Use with ComplexPlot3D:

In[9]:=
ComplexPlot3D[(-1 + z)/(1 + z + z^2), {z, -2 - 2 I, 2 + 2 I}, ColorFunction -> (ResourceFunction["DLMFHue"][#8/(2 \[Pi])] &), ColorFunctionScaling -> False, Exclusions -> None, PlotRange -> All]
Out[9]=

Properties and Relations (2) 

DLMFHue is a transformed version of Hue:

In[10]:=
With[{hf = Interpolation[Transpose[{Range[0, 1, 1/4], {0, 1/6, 1/2, 2/3, 1}}],
     InterpolationOrder -> 1]},
 dlmfhue[h_?NumericQ, rest___?NumericQ] := Hue[hf[Mod[h, 1]], rest]]
In[11]:=
{Graphics[{ResourceFunction["DLMFHue"][1/8], Disk[]}], Graphics[{dlmfhue[1/8], Disk[]}]}
Out[11]=

In plot functions, use ColorFunctionScaling to control global scaling of variables:

In[12]:=
Table[DensityPlot[x, {x, -2, 3}, {y, 0, 1}, FrameTicks -> None, ColorFunction -> (ResourceFunction["DLMFHue"][2/3, #1] &), ColorFunctionScaling -> t], {t, {False, True}}]
Out[12]=

Possible Issues (1) 

Saturation and brightness values outside of the {0, 1} range will be clipped:

In[13]:=
Graphics[Table[{ResourceFunction["DLMFHue"][1/3, s], EdgeForm[Gray], Rectangle[{4 s, 0}]}, {s, 0 - 1/4, 1 + 1/4, 1/4}]]
Out[13]=
In[14]:=
Graphics[Table[{ResourceFunction["DLMFHue"][1/3, 1, b], EdgeForm[Gray], Rectangle[{4 b, 0}]}, {b, 0 - 1/4, 1 + 1/4, 1/4}]]
Out[14]=

Version History

  • 1.0.0 – 22 December 2020

Related Resources

License Information