I am having trouble creating a bar graph where the color of the bars depend on the y-value they represent. I am able to do this manually, but I'd like to have code to do it systematically, so that if I wanted to create a graph for a specific observation group, the color would be dependent on a certain "level".
I have tried using the cond( ) command as well as the -if- expression in many iterations, as well as using macros but I am just not getting it to work out.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id level) str7 area str6 col 1 1 "kitchen" "lime" 1 1 "dining" "lime" 1 1 "bed" "lime" 4 5 "bed" "red" 4 3 "garage" "yellow" 5 4 "dining" "orange" end
I would also like to "hone" in on certain IDs only to isolate them and only graph their data:
This is how I would manually create graph for id==1:
Code:
graph bar (asis) level if id==1, over(area) bar(1, fcolor(lime))
What if the level was 3?
I'd like it to automatically make the bar yellow as if somehow I were saying
Code:
bar(1,fcolor(`col'))
0 Response to Creating Bar Graph colors depending on Y-value
Post a Comment