2
$\begingroup$

With the following:

RadialAxisPlot[{3, 8, 5}, AxesLabel -> {"a", "b", "c"}]

I obtain the expected output:

Radial axis plot

But I would like the regions between the concentric circles to have different colours. I know there is a function called RadialGradientFilling, but the following does not work:

Graphics[
    {
        RadialGradientFilling[{2, 6, 10} -> {Green, Purple, Red}],
        RadialAxisPlot[{3, 8, 5}, AxesLabel -> {"a", "b", "c"}]
    }
]

Am I overlooking a simple option somewhere?

Thanks in advance.

$\endgroup$

2 Answers 2

4
$\begingroup$

Although the radial ticks suggest that the circle radii range from 0 to 10, they actually range from 0 to 1. So we can add as Prolog or Epilog a disk with unit radius styled using RadialGradientFilling. Adding opacity to the gradient filling makes the main plot elements more visible:

RadialAxisPlot[{3, 8, 5}, AxesLabel -> {"a", "b", "c"}, 
 Prolog -> {RadialGradientFilling[{.2, .6, 1.} -> 
   (Append[.3] /@ {Green, Purple, Red})], Disk[]}] 

enter image description here

A variation using annuli each with its own gradient filling:

RadialAxisPlot[{3, 8, 5}, AxesLabel -> {"a", "b", "c"}, 
 Prolog -> 
   MapThread[{RadialGradientFilling[Append[.3] /@ {White, #2}], Annulus[{0, 0}, #]} &, 
   {Partition[{0.001, .2, .6, 1}, 2, 1], {Green, Purple, Red}}]] 

enter image description here

Or use annuli with different colors without gradient filling:

RadialAxisPlot[{3, 8, 5}, AxesLabel -> {"a", "b", "c"}, 
 Prolog ->  MapThread[{Opacity[.25, #2], Annulus[{0, 0}, #]} &, 
   {Partition[{0.001, .2, .6, 1}, 2, 1], {Green, Purple, Red}}]] 

enter image description here

If the gridlines are linear (as the option GridLines -> "Polygon" will produce) the directives RadialGradientFilling and LinearGradientFilling do not give nice pictures:

Row[RadialAxisPlot[{3, 8, 5}, ImageSize -> 300, 
     AxesLabel -> {"a", "b", "c"},  GridLines -> "Polygon", 
     Prolog -> {RadialGradientFilling[{.2, .6, 1.} -> 
        (Append[.3] /@ {Green, Purple, Red})], #}] & /@ 
  {Disk[], Polygon[CirclePoints[{1, Pi/2}, 3]]}, Spacer[10]]

enter image description here

The following function lGFPolygon produces a regular polygon with linear-radial gradient filling:

ClearAll[lGFPolygon]
lGFPolygon[n_][colors_, weights_ : Automatic, opacity_ : .3] := 
 Module[{cp = Most @ Subdivide[0, 2 Pi, n], 
   c = If[Head[colors] === String, colors, 
       (weights /. Automatic -> Most[Subdivide[Length@colors]]) -> 
         (Append[opacity] /@ colors)]}, 
  tri = {LinearGradientFilling[c, Top], Polygon @ Prepend[{0, 0}]@
      Transpose[Through[{Cos, Sin} @ Take[Pi/2 - Pi/n + cp, 2]]]}; 
  Table[Rotate[tri, a, {0, 0}], {a, Pi/n + cp}]]

Examples:

RadialAxisPlot[{3, 8, 5}, AxesLabel -> {"a", "b", "c"}, 
 GridLines -> "Polygon", 
 Prolog -> { lGFPolygon[3][{Green, Purple, Red}, {.2, .6, 1}, .5]}]

enter image description here

RadialAxisPlot[{3, 8, 5}, AxesLabel -> {"a", "b", "c"}, 
 GridLines -> "Polygon", 
 Prolog -> { lGFPolygon[3]["SunsetColors"]}] 

enter image description here

data = {3, 8, 5, 4, 3, 2, 5};
RadialAxisPlot[data, AxesLabel -> {"a", "b", "c", "d", "e", "f", "g"}, 
 GridLines -> "Polygon", 
 Prolog -> {lGFPolygon[Length@data][{Green, Purple, Red}, {.2, .6, 1}, .5]}] 

enter image description here

Update: An alternative way to get linear-radial filling for polygon grid lines is to use DensityPlot of distance from the boundary of a regular polygon:

ClearAll[dP]
dP[n_, colors_, vals_ : Automatic, opacity_ : .5] := 
 Module[{rp = RegularPolygon[{1, Pi/2}, n], rd}, 
  rd = RegionDistance[RegionBoundary @ rp]; 
  DensityPlot[rd[{x, y}], {x, y} ∈ rp,  
  Exclusions -> None, 
   ColorFunction -> If[Head[colors] === String, colors, 
     Blend[Thread[{1 - (vals /. Automatic -> Rest[Subdivide[Length@colors]]), 
         Append[opacity] /@ colors}], #] &],  
   PlotPoints -> 100]]

Examples:

RadialAxisPlot[{1, 3, 8, 4, 2, 1, 4}, GridLines -> "Polygon", 
 AxesLabel -> {"a", "b", "c", "d", "e", "f", "g"},
 LabelStyle -> 16,
 TicksStyle -> Directive[FontColor -> Darker @ Gray, White],
 GridLinesStyle -> White,
 AxesStyle -> White, Filling -> None,
 Prolog -> dP[7, {Green, Purple, Red}, {0, .6, 1}][[1]]] 

enter image description here

Use Prolog -> dP[Length @ data ,"SunsetColors"][[1]] to get

enter image description here

Use Prolog -> (dP[Length @ data, "Rainbow"][[1]]/. c_?ColorQ :> Opacity[.3, c]) to get

enter image description here

$\endgroup$
2
$\begingroup$

Something like this?

RadialAxisPlot[{3, 8, 5}, AxesLabel -> {"a", "b", "c"}, 
 Prolog -> {RadialGradientFilling[{.2, .6, 1} -> {Green, Purple, 
      Red}, {1/2, 1/2}], Disk[{0, 0}, 1]}]

enter image description here

$\endgroup$

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.