Hello everyone,
I need to produce some graphs and I would like to add the total n by two categories to the labels. As you can see on the picture I attached, there are two variables on the yaxis (region and year). The number in parenthesis is the total n for each region but the thing is that I want it to be for each year different, not just for each region different. For example, in 2022 there were 100 cars in region A and 120 cars in region B.
Is there a way to edit the labels of region by year? I used the following code:

I need to produce some graphs and I would like to add the total n by two categories to the labels. As you can see on the picture I attached, there are two variables on the yaxis (region and year). The number in parenthesis is the total n for each region but the thing is that I want it to be for each year different, not just for each region different. For example, in 2022 there were 100 cars in region A and 120 cars in region B.
Is there a way to edit the labels of region by year? I used the following code:
Code:
graph hbar (count), over(car_class) over(region, relabel(1 `" "A" "(174 cars)" "' 2 `" "B" "(144 cars)" "')) over(year) percent stack asyvars /// ytitle("Percent") /// bar(1, fcolor(orange_red*.9) lw(none)) /// bar(2, fcolor(orange) lw(none)) /// bar(3, fcolor(yellow) lw(none)) /// bar(4, fcolor(green) lw(none)) /// bar(5, fcolor(blue*.3) lw(none)) /// blabel(bar, format(%4.0f) size(medium) position(center)) /// title("AAABBBB")
Comment