Hello. I have a question about making stacked bar graphs that show both the size and the proportion of each variable.
For the following example,
I was able to make bar graphs with the size of each variable and the proportion of each variable of each firm with the following commands:
levelsof firm, local(fn)
foreach f of local fn {
preserve
keep if firm == "`f'"
graph bar v1-v3 , over(year) stack title("`f'") blabel(bar, pos(center))
graph export size_of_variables_`f'.png, replace
restore
}
levelsof firm, local(fn)
foreach f of local fn {
preserve
keep if firm == "`f'"
graph bar v1-v3 , percentage over(year) stack title("`f'") blabel(bar, pos(center))
graph export proportion_of_variables_`f'.png, replace
restore
}
This yields the following graphs:

What I want is to combine the two features of the graphs, so that the graphs have varying heights depending on the size of the variable, and the labels show the percentage(proportion) of each variable. Ideally, I would want my graph to look something like this:

I would greatly appreciate any help regarding this topic. Thank you.
For the following example,
year | firm | v1 | v2 | v3 |
2000 | A | 10 | 20 | 30 |
2001 | A | 30 | 50 | 10 |
2000 | B | 50 | 40 | 20 |
2001 | B | 60 | 10 | 50 |
levelsof firm, local(fn)
foreach f of local fn {
preserve
keep if firm == "`f'"
graph bar v1-v3 , over(year) stack title("`f'") blabel(bar, pos(center))
graph export size_of_variables_`f'.png, replace
restore
}
levelsof firm, local(fn)
foreach f of local fn {
preserve
keep if firm == "`f'"
graph bar v1-v3 , percentage over(year) stack title("`f'") blabel(bar, pos(center))
graph export proportion_of_variables_`f'.png, replace
restore
}
This yields the following graphs:
What I want is to combine the two features of the graphs, so that the graphs have varying heights depending on the size of the variable, and the labels show the percentage(proportion) of each variable. Ideally, I would want my graph to look something like this:
I would greatly appreciate any help regarding this topic. Thank you.
Comment