1
$\begingroup$

I would like to put a legend label above a legend generated from PieChart / ChartLegends. The closest I could come is with

PieChart[{1, 2, 3, 4},
 FrameLabel -> {"Situations", "Score"},
 PlotLabel -> "Exemple de graphique en tarte",
 ChartLegends -> {"1", "2", "3", "4"},
 BaseStyle -> {FontSize -> 14, FontColor -> Black},
 Epilog -> Text["Situations", {1.2, 0.5}]
 ]

but the text "situation" is out of the plot area and is only partially visible, as seen below. I use MMA 10.0 enter image description here

$\endgroup$
1
  • $\begingroup$ PieChart[{1, 2, 3, 4}, PlotLabel -> "Exemple de graphique en tarte", ChartLegends -> SwatchLegend[{"1", "2", "3", "4"}, LegendLabel -> "Situations"], BaseStyle -> {FontSize -> 14, FontColor -> Black}] $\endgroup$
    – Bob Hanlon
    Mar 20, 2021 at 20:47

1 Answer 1

2
$\begingroup$

You can add the option LegendAppearance:

PieChart[{1, 2, 3, 4}, PlotLabel -> "Exemple de graphique en tarte", 
 ChartLegends -> {"1", "2", "3", "4"}, 
 LegendAppearance -> {LegendLabel -> Style["legend", Red, 16]}, 
 BaseStyle -> {FontSize -> 14, FontColor -> Black}]

or, alternatively, use the LegendLabel option inside SwatchLegend:

PieChart[{1, 2, 3, 4}, PlotLabel -> "Exemple de graphique en tarte", 
 ChartLegends -> SwatchLegend[{"1", "2", "3", "4"}, 
   LegendLabel -> Style["legend", Red, 16]], 
 BaseStyle -> {FontSize -> 14, FontColor -> Black}]

to get

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.