Im trying to generate a bar chart with one of the bars representing the average value across all IDs. And that bar should be the only differentiated color among the others.
So using syuse data, this is what i attempted with an error rejecting the "if" option
sysuse auto, clear
preserve
sort price
*add an observation for the average
expand 2 in L
replace price = . in L
egen avgprice =mean(price)
replace price = avgprice in L
replace make = "Average" in L
graph hbar price , over(make, sort(1) descending axis(off)) blabel(group, size(tiny)) bar(1 , bcolor(maroon))
*change the color of only the bar for "Average"
graph hbar price , over(make, sort(1) descending axis(off)) blabel(group, size(tiny)) bar(1 if make == "Average", bcolor(maroon))
restore
error: option if not allowed
How do I get a bar graph with one of the bars representing the average score of the values across the IDs and highlighting that with a different color? Also, I do not want the average bar to be included in the legend.
Thank you for your assistance.
Related Posts with changing the color of just one bar in a single category bar chart
Creating Variable and Dummy Variable Based on Condition Met in Each YearI am trying to create dummy variable based on conditions met in each the year - I will have two vari…
Number of Estimated Coefficients in a RegressionIs there a way to display the number coefficients estimated in a regression? I am estimating differe…
"variable at_exp_share11 already defined" is always displayed when I run the command."variable at_exp_share11 already defined" is always displayed when I run the command. But I can conf…
Compute Estimated Hazard and Plot Estimated Hazard Curve after Fitting a xtmelogit Survival Model in StataThe dataset is presented below, insheet using "https://ift.tt/aXA9elG", comma foreach i of varlist …
Moving average with panel dataHello all, Below is an example of the data I am working with: Code: input float(year quarter mile…
Subscribe to:
Post Comments (Atom)
0 Response to changing the color of just one bar in a single category bar chart
Post a Comment