Hello,
I'm trying to add labels to the twoway spanning bar chart. I would like to add percentages of expenditure shares, which is a different variable from the ones I used for the chart (pc) on top of each bar. I could find some answers for normal bar charts but not for this kind of spanning chart. so:
1) how can I add bar labels based on a "pc" variable, which is not used for making the bar chart?
And also:
2) how can I get rid of EF9 from the legend?
Thank you for your help!
some of my code:
figure where I want to put on top percentages of expenditure shares (pc based on variable exp)
I'm trying to add labels to the twoway spanning bar chart. I would like to add percentages of expenditure shares, which is a different variable from the ones I used for the chart (pc) on top of each bar. I could find some answers for normal bar charts but not for this kind of spanning chart. so:
1) how can I add bar labels based on a "pc" variable, which is not used for making the bar chart?
And also:
2) how can I get rid of EF9 from the legend?
Thank you for your help!
some of my code:
Code:
twoway bar EF1 exp_cum , bartype(spanning) base(0) || bar EF2 exp_cum, bartype(spanning) base(0) || bar EF3 exp_cum, bartype(spanning) base(0) || bar EF4 exp_cum, bartype(spanning) base(0) || bar EF5 exp_cum, bartype(spanning) base(0) || bar EF6 exp_cum, bartype(spanning) base(0) || bar EF7 exp_cum, bartype(spanning) base(0)|| bar EF8 exp_cum, bartype(spanning) base(0)|| bar EF9 exp_cum, bartype(spanning) base(0) ytitle("yearly avergae household energy footprint GJ") xla(0(100)730)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(EF exp exp_cum) str22 var13 float(EF1 EF2 EF3 EF4 EF5 EF6 EF7 EF8) byte EF9 float(grouping pc) .168634 0 0 "recreation and culture" .168634 . . . . . . . . 9 0 .3608554 26.146544 26.146544 "clothing and footwear" . .3608554 . . . . . . . 9 3.5836484 1.058974 32.42573 58.57227 "other" . . 1.058974 . . . . . . 9 4.444275 1.4442434 159.6117 218.18398 "food" . . . 1.4442434 . . . . . 9 21.8764 1.5882757 433.2895 651.4734 "petrol/diesel" . . . . 1.5882757 . . . . 9 59.38671 1.6788563 26.1177 677.5911 "electricity" . . . . . 1.6788563 . . . 9 3.579695 4.945707 40.68476 718.2759 "firewood" . . . . . . 4.945707 . . 9 5.576259 7.159899 4.2545524 722.5305 "charcoal" . . . . . . . 7.159899 . 9 .58312947 . 7.076372 729.6068 "" . . . . . . . . . 9 .9698884 end
Comment