1
$\begingroup$

Related: PieChart and legending issues

I have the following list:

   list = {{"Nordrhein-Westfalen", 
   0.19148936170212766`}, {"Baden-Württemberg", 
   0.1466359976998275`}, {"Niedersachsen", 
   0.07245543415756182`}, {"Bayern", 
   0.1311098332374928`}, {"Rheinland-Pfalz", 
   0.05117883841288096`}, {"Schleswig-Holstein", 
   0.03220241518113859`}, {"Brandenburg", 
   0.08970672800460035`}, {"Thüringen", 
   0.0097757331799885`}, {"Sachsen-Anhalt", 
   0.006900517538815411`}, {"Hessen", 
   0.09200690051753882`}, {"Mecklenburg-Vorpommern", 
   0.010350776308223116`}, {"Berlin", 
   0.08338125359401956`}, {"Saarland", 
   0.014951121334100058`}, {"Bremen", 
   0.011500862564692352`}, {"Hamburg", 0.05635422656699252`}}

No problem making a colored PieChart

PieChart[Last /@ list, ChartLegends -> (First /@ list)]

gives:

enter image description here

While playing around I tried:

    PieChart[Last /@ list, ColorFunction -> GrayLevel, 
 ChartLegends -> (First /@ list)]

and got:

enter image description here

O.K. its ugly but the legends are not appropriately colored. Can anyone tell my, why?

Remark (2018-03-26): I didn't have seen this as a pure duplicate (- and still do not. The question for me is that given an explicit ColorFunction this is taken to color the pieces of the chart but not the Legends. For me this is not very logical. When specifying a colorfunction I expect that this is not only used to color the Pie but also the legends.

$\endgroup$
0

1 Answer 1

2
$\begingroup$
list = {{"Nordrhein-Westfalen", 0.19148936170212766`}, {"Baden-Württemberg", 
    0.1466359976998275`}, {"Niedersachsen", 0.07245543415756182`}, {"Bayern", 
    0.1311098332374928`}, {"Rheinland-Pfalz", 
    0.05117883841288096`}, {"Schleswig-Holstein", 
    0.03220241518113859`}, {"Brandenburg", 
    0.08970672800460035`}, {"Thüringen", 
    0.0097757331799885`}, {"Sachsen-Anhalt", 
    0.006900517538815411`}, {"Hessen", 
    0.09200690051753882`}, {"Mecklenburg-Vorpommern", 
    0.010350776308223116`}, {"Berlin", 0.08338125359401956`}, {"Saarland", 
    0.014951121334100058`}, {"Bremen", 0.011500862564692352`}, {"Hamburg", 
    0.05635422656699252`}};

I don't know the cause of the problem; however, you can use

PieChart[Legended[#[[2]], #[[1]]] & /@ list, ColorFunction -> GrayLevel]

enter image description here

For a clearer Tooltip

PieChart[Tooltip[Legended[#[[2]], #[[1]]], Column@#] & /@ list, 
 ColorFunction -> GrayLevel]
$\endgroup$

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