Dear Statalist, I'm working on several graph bar and this is my code:
graph bar (sum) frequency
if <several if condition, depending on report required>,
over(Status)
over(Type, label(labsize(vsmall)) )
over(Year, label(labsize(vsmall)))
bar(1, fcolor(cranberry) fintensity(inten100))
bar(2, fcolor(dkorange) fintensity(inten100))
bar(3, fcolor(dkgreen) fintensity(inten100))
bar(4, fcolor(forest_green) fintensity(inten100))
bar(5, fcolor(gold) fintensity(inten100))
ytitle("")
ylabel(, labsize(vsmall))
title("This is my title", size(small))
legend(on size(vsmall)
symxsize(2) symysize(2))
scheme(s2color)
graphregion(fcolor(white) ifcolor(none))
blabel(total, size(vsmall))
bargap(20)
As you can see, there is a dummy variable called frequency to count the number of record respecting to the group condition and there are 3 over() conditions. The first one is based on a variable called Status. This is a category with only five values. As espected, the bar option are used depending on the Status values presence in the dataset resulting from the <if> condition.
e.g., if I have at least one recordset for each Status value, all the 5 bar option and colours are used, if I have a dataset with records containing only status 1, 4, 5, only the first 3 bar condition are used.
Do you know if there is a way to bind the bar option to the Status value, in order to keep the same color for the same Status value? This will be very useful in reading similar graph, because the same Status same color.
Thank you in advance.
Giuseppe
graph bar (sum) frequency
if <several if condition, depending on report required>,
over(Status)
over(Type, label(labsize(vsmall)) )
over(Year, label(labsize(vsmall)))
bar(1, fcolor(cranberry) fintensity(inten100))
bar(2, fcolor(dkorange) fintensity(inten100))
bar(3, fcolor(dkgreen) fintensity(inten100))
bar(4, fcolor(forest_green) fintensity(inten100))
bar(5, fcolor(gold) fintensity(inten100))
ytitle("")
ylabel(, labsize(vsmall))
title("This is my title", size(small))
legend(on size(vsmall)
symxsize(2) symysize(2))
scheme(s2color)
graphregion(fcolor(white) ifcolor(none))
blabel(total, size(vsmall))
bargap(20)
As you can see, there is a dummy variable called frequency to count the number of record respecting to the group condition and there are 3 over() conditions. The first one is based on a variable called Status. This is a category with only five values. As espected, the bar option are used depending on the Status values presence in the dataset resulting from the <if> condition.
e.g., if I have at least one recordset for each Status value, all the 5 bar option and colours are used, if I have a dataset with records containing only status 1, 4, 5, only the first 3 bar condition are used.
Do you know if there is a way to bind the bar option to the Status value, in order to keep the same color for the same Status value? This will be very useful in reading similar graph, because the same Status same color.
Thank you in advance.
Giuseppe
Comment