I was browsing through the new features of Mathematica 11 and found this picture on the website:

distributions

I'm trying to replicate this graphic (except for the logo in the middle of course) by means of the SectorChart function, but it seems very difficult to make it work. I got as far as this (only choosing a few sectors for demonstration purposes):

  size1 = 20; size2 = 8;
secDat = Table[{1, 1}, {x, 1, size2}, {y, 1, size1}];
SectorChart[secDat, ChartLayout -> "Grouped", 
 PerformanceGoal -> "Speed", SectorOrigin -> {Automatic, 10}, 
 ChartLabels -> 
  Placed[Table["Label" <> ToString@x, {x, 1, size1}], "RadialInside", 
   Rotate[#, 90 Degree] &], 
 ChartLegends -> 
  Placed[Table["Legend" <> ToString@x, {x, 1, size2}], Below]]

Can someones help me with

  1. aligning the labels such that they are in line with the grid lines like shown in the graphic. I tried to use the Rotate function but it rotates all labels
  2. only showing the labels in the inner most layer
  3. finding a way to automatically color only specific sections and not others like it is shown in the graphic

Any help appreciated!

  • 1
    See SectorChart. – Kuba Jul 27 '17 at 10:40
  • 2
    Searke says: "What makes you so sure it was written 100% in Wolfram Language Code? Things like this tend to go thru design and are edited to fit in more with the style of the webpage." – J. M. is computer-less Jul 27 '17 at 10:45
  • Thanks all, I guess I just assumed it was made with Mathematica :). Sector Chart seems a possible way, but also looks quite different as in the picture. Any ideas how to start creating a chart like that with SectorChart? – holistic Jul 27 '17 at 10:50
  • 2
    You could start with ChartLabels -> Placed[Automatic, "RadialInside",Rotate[#,somefunction]&], SectorOrigin -> {Automatic, 4} in Sector chart – Ruud3.1415 Jul 27 '17 at 11:26
  • 1
    It could also just be a PieChart with opactities set and the logo / dashed lines added on top. – b3m2a1 Jul 30 '17 at 23:59
up vote 10 down vote accepted
+300

You could use Graphics and built it up yourself. One way to start may be:

Options[versionChart] = {
  LabelStyle -> Directive[White, Medium],
  GridLinesStyle -> Directive[Thick, Gray],
  ImageSize -> Large,
  ColorFunction -> ColorData[92],
  "CoreSize" -> 20
};

versionChart[data_,OptionsPattern[]] := With[{
    layers = Union@Flatten[Last/@data],
    elementCount = Length@DeleteDuplicates@Flatten[First/@data],
    innerDiskSize = OptionValue["CoreSize"]
  },
  Graphics[{
      (* draw inner part (except labels) *)
      Darker@Red,Disk[{0,0},innerDiskSize],
      (* generate sectors *)
      (* first, Table over all layers *)
      Table[
        (* for each layer, check which elements are active on this layer *)
        With[{elems=Flatten@Position[data,{_, _?(MemberQ[#,layer]&)}]},
          (* Table through all active elements *)
          Table[{
            (* set the sector color *)
            OptionValue[ColorFunction][layer],
            (* draw the sector *)
            Annulus[{0,0}, layer + innerDiskSize + {0,1}, {e-1/2, e + 1-1/2} 2 \[Pi] / elementCount],
            (* draw labels *)
            With[{angle=(e+1/2-1/2)2\[Pi]/elementCount},
              (* avoid upside-down labels *)
              If[\[Pi]/2<angle<3\[Pi]/2,
                Rotate[Text[Style[data[[e,1]], OptionValue[LabelStyle]],{-(innerDiskSize-1/2),0},{-1,0}],angle+\[Pi],{0,0}],
                Rotate[Text[Style[data[[e,1]], OptionValue[LabelStyle]],{(innerDiskSize-1/2),0},{1,0}], angle, {0,0}]
              ]
            ]
          }, {e,elems}]
        ]~Join~Table[
          (* draw intersection lines *)
          {OptionValue[GridLinesStyle], Line[Outer[Times,(innerDiskSize + layer + {0.2,0.8}), AngleVector[2\[Pi] (n-1/2)/elementCount]]]},
          {n, elementCount}
        ]~Join~{
          (* draw MMA polygon *)
          White,
          Polygon@(Join[#,{First[#]}]&)@Riffle[
            CirclePoints[{0.5 innerDiskSize,0},5],
            CirclePoints[{0.3 innerDiskSize,30 Degree},5]
          ]
        },
        {layer,layers}
      ]
    }, 
    ImageSize -> OptionValue[ImageSize]
  ]
]

Careful: this code is not super-robust, i.e. I do not check if the user gave good arguments and options. You may want to add this yourself, but for this post I think it is best if my code remains "clutter-free".

versionChart expects a List as argument, which shall be of the form {{label1, {layerlist1}}, {label2, {layerlist2}}, ...}, where the layerlists are integers (incl. 0), and signify on which layers this data should have a sector. For example

versionChart[{
  {"uniform", {0, 4}},
  {"beta", {1, 3}},
  {"gamma", {0, 2}},
  {"delta", {3, 5}}
}]

gives

simple example output

and

versionChart[{#, RandomChoice[Range[0, 5], 3]} & /@ Names["*Distribution"],
 LabelStyle -> 
   Directive[
     LightRed, 
     FontSize -> Scaled[0.01], 
     FontFamily -> "Comic Sans"
  ],
  "CoreSize" -> 50,
  ColorFunction -> ColorData[93],
  ImageSize -> 2000,
  GridLinesStyle -> Gray
]

gives

enter image description here

For export, you may want to use Rasterize with a high setting for ImageResolution, so the text does not get scrambled.

  • Interesting solution, thank you! Yes, it looks quite similar to graphics. Can you also add some grid lines? – holistic Jul 31 '17 at 13:49
  • @holistic I added grid lines. Do you also want the star in the inside to look like the one in your figure? Or is this irrelevant? – JEM_Mosig Jul 31 '17 at 21:30
  • No, it's fine like that ;)...Awesome! Thank you!! – holistic Jul 31 '17 at 21:53
  • 1
    Wow! My enthusiasm, however, is tempered by your font choice. – J. M. is computer-less Aug 1 '17 at 2:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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