Hello Stata Community,
I am currently working on the graph with the distribution of taxes. Now I want to add a line with the total value of the variables used in the stack graph but I don't know how to do it. Here is my code:
// f) Stacked graph for Spain & US
//new variable with country specifications:
gen countryspec = 1 if country == "Spain"
replace countryspec = 2 if country == "United States"
label define countryspecname 1 "Spain" ///
2 "United States"
label values countryspec countryspecname
// Graph:
graph bar (sum) value if value > 0.05, ///
over(tax, label(labsize(vsmall))) ///
over(year) by(countryspec) asyvars stack ///
line sum year ///
bargap(10) ///
line value ///
ytitle("Tax revenue as % of GDP", size(small)) ///
note("Data source: OECD, 2022") ///
xsize(10) ///
ysize(6) ///
title("Tax structure of US and Spain", span size(small)) ///
blabel(bar, orientation(horizontal) position(center) size(vsmall) color(white) format(%4.1f))
In the End it should look like this:

Thanks in advance
I am currently working on the graph with the distribution of taxes. Now I want to add a line with the total value of the variables used in the stack graph but I don't know how to do it. Here is my code:
// f) Stacked graph for Spain & US
//new variable with country specifications:
gen countryspec = 1 if country == "Spain"
replace countryspec = 2 if country == "United States"
label define countryspecname 1 "Spain" ///
2 "United States"
label values countryspec countryspecname
// Graph:
graph bar (sum) value if value > 0.05, ///
over(tax, label(labsize(vsmall))) ///
over(year) by(countryspec) asyvars stack ///
line sum year ///
bargap(10) ///
line value ///
ytitle("Tax revenue as % of GDP", size(small)) ///
note("Data source: OECD, 2022") ///
xsize(10) ///
ysize(6) ///
title("Tax structure of US and Spain", span size(small)) ///
blabel(bar, orientation(horizontal) position(center) size(vsmall) color(white) format(%4.1f))
In the End it should look like this:
Thanks in advance

