1
$\begingroup$

1. Problem statement

Some game days before the end of a league season I want to show the possible final rankings (depending upon the results of the outstanding games).

2. Example data (situation after the penultimate game day)

data =
  <|"Bayern" -> <|"High" -> 1, "Now" -> 1, "Low" -> 1|>,
   "Leipzig" -> <|"High" -> 2, "Now" -> 2, "Low" -> 2|>,
   "Dortmund" -> <|"High" -> 3, "Now" -> 3, "Low" -> 4|>,
   "Wolsburg" -> <|"High" -> 3, "Now" -> 4, "Low" -> 4|>,
   "Frankfurt" -> <|"High" -> 5, "Now" -> 5, "Low" -> 5|>,
   "Leverkusen" -> <|"High" -> 6, "Now" -> 6, "Low" -> 6|>,
   "Union" -> <|"High" -> 7, "Now" -> 7, "Low" -> 10|>,
   "Gladbach" -> <|"High" -> 7, "Now" -> 8, "Low" -> 10|>,
   "Stuttgart" -> <|"High" -> 7, "Now" -> 9, "Low" -> 10|>,
   "Freiburg" -> <|"High" -> 7, "Now" -> 10, "Low" -> 10|>,
   "Hoffenheim" -> <|"High" -> 11, "Now" -> 11, "Low" -> 11|>,
   "Augsburg" -> <|"High" -> 12, "Now" -> 12, "Low" -> 14|>,
   "Mainz" -> <|"High" -> 12, "Now" -> 13, "Low" -> 14|>,
   "Hertha" -> <|"High" -> 12, "Now" -> 14, "Low" -> 15|>,
   "Bielefeld" -> <|"High" -> 14, "Now" -> 15, "Low" -> 17|>,
   "Bremen" -> <|"High" -> 15, "Now" -> 16, "Low" -> 17|>,
   "Koeln" -> <|"High" -> 15, "Now" -> 17, "Low" -> 17|>,
   "Schalke" -> <|"High" -> 18, "Now" -> 18, "Low" -> 18|>|>;

3. Corresponding Plot

enter image description here

  • Red: Actual ranking
  • White: Best possible ranking after last game day
  • Black: Worst possible ranking after last game day

A few matchdays earlier the prediction bands might have looked like this:

enter image description here

4. Question

What could be possible ways to produce a similar Plot (except the logos)?

$\endgroup$

1 Answer 1

3
$\begingroup$
ds = Dataset[data];

styleCode = Association[Join[
   Thread[ToString /@ Range[Length@ds] -> ""], 
   Thread[ToString /@ Range[#High, #Low] -> 
     (Range[#High, #Low] /. 
       {Except[#High | #Low, _Integer] -> Style["", Darker@Darker@Gray], 
        #High ->  Style[#High, White, Bold, FontColor -> Black], 
        #Low ->   Style[#Low, Black, Bold,  FontColor -> White]})], 
   {ToString @ #Now -> Style[#Now, Darker @ Red, Bold, FontColor -> White]}]]&;

options = {HeaderBackground -> {Lighter @ LightGray, White}, 
   ItemSize -> 3.5, 
   MaxItems -> {All, All}, 
   Alignment -> {Center, Automatic}, 
   ItemStyle -> {All -> {FontSize -> 20}}, 
   Background -> {{{Lighter @ Lighter @ Gray, Lighter @ LightGray}}, 
     If[Head[#] === Style, #[[2]]] &}};

Dataset[ds[All, styleCode], options]

enter image description here

See also:

Christopher Carlson, New 12.1 Dataset Interactive Controls and Formatting Options

$\endgroup$
1
  • $\begingroup$ I am extremely amazed - wonderful! $\endgroup$
    – eldo
    Oct 10, 2023 at 11:48

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.