3
$\begingroup$

I have the following code to produce an almost fancy BarChart:

countries = CountryData["G7"]; data = {{2, 1, 1.5, 3, 3, 2.5, 4}, {-2, -1, -1.5, -3, -3, -2.5, -2}}; BarChart[data, PlotLabel -> "GDP Per Capita", PlotTheme -> "Business", ChartLabels -> Placed[countries, Below, Rotate[#, Pi/2.4] &], ChartStyle -> {{Blue, Green}, None}, ChartLegends -> {{"high", "low"}, None}] 

enter image description here

My goal is to generate the following format:

enter image description here

I want to have the following modifications to convert my BarChart above.

1- Add a box Downside Scenario to the top of the bar chart in Brown color, and inside the same box add a line of text in small fonts like This is a scenario parameter set

2- Add a secondary plot label GDP Per Capita in bold

3- add a second line of text under GDP per capita such as parameter domain: {1,2,3}

$\endgroup$

2 Answers 2

8
$\begingroup$

First thoughts...

countries = CountryData["G7"]; data = {{2, 1, 1.5, 3, 3, 2.5, 4}, {-2, -1, -1.5, -3, -3, -2.5, -2}}; Column[{ TextCell["GDP Per Capital", "Section", FontColor -> White], TextCell["This is a scenario parameter set", FontSize -> 12, FontColor -> White], "", TextCell["WorldGDP in 2020", FontWeight -> Bold, FontSize -> 20], TextCell["parameter domain:{1,2,3}", FontWeight -> Bold, FontSize -> 12], "", TextCell["% Difference from baseline and contributions in % pts", "TI"], BarChart[data, PlotTheme -> "Business", ChartLabels -> Placed[countries, Below, Rotate[#, Pi/2.4] &], ChartStyle -> {{Blue, Green}, None}, ChartLegends -> {{"high", "low"}, None}, ImageSize -> 500] }, Alignment -> Center, Background -> {Automatic, {1 -> Darker[Red], 2 -> Darker[Red]}}] 

enter image description here

Vary your text and colors as desired.

$\endgroup$
1
  • $\begingroup$ It is a nice figure. thanks very much. $\endgroup$ Commented May 26, 2021 at 19:51
2
$\begingroup$

Took the liberty to transpose the data and modified the format of the plot. I think as the items grow, this would scale better.

countries = CountryData["G7"]; data = Transpose@{{2, 1, 1.5, 3, 3, 2.5, 4}, {-2, -1, -1.5, -3, -3, -2.5, -2}}; flags = Column[{#[EntityProperty["Country", "Flag"]] // ImageResize[#, 40] &, #[EntityProperty["Country", "Name"]]}, Alignment -> Center] & /@ countries; cols = {Directive @@ {Darker@Green, HatchFilling["Diagonal", 2, 5]} , Directive @@ {Lighter@Red, HatchFilling[-1, 2, 5]} } BarChart[ Tooltip@data , PlotLabel -> "GDP Per Capita" , PlotTheme -> "Business" , ChartLayout -> "Stacked" , ChartLegends -> Placed[ SwatchLegend[cols, {"high", "low"} , LegendLayout -> "Column"] , After ] , ChartStyle -> ConstantArray[cols, Length@data] , ChartLabels -> { flags, None} , Frame -> {{True, False}, {True, False}} , PlotRangePadding -> {0.5, 0.2} , ImageSize -> Large ] 

Stacked bar chart template for G7 GDP data

$\endgroup$
1
  • 1
    $\begingroup$ I agree that this version looks more compact and interesting. $\endgroup$ Commented Dec 11, 2024 at 16:20

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.