我正在尝试通过覆盖twoway bar
来更改rcap
图中条形的颜色。
Stata不允许我使用color()
,bcolor()
或bar(1, color())
选项。
这是我的代码:
twoway (bar meanVAR1 Treatment) (rcap loVAR1 hiVAR1 Treatment), yscale(off) ///
ytitle(Percent) xtitle(Exp whether treated) xlabel(minmax) legend(off) ///
name(experience, replace) graphregion(fcolor(white) ifcolor(white)) ///
plotregion(fcolor(white) ifcolor(white))
如何更改图形中条形的颜色?
答案 0 :(得分:1)
如果只想为所有条形指定颜色,则只需将color()
选项放置在 twoway bar
图的内部:
sysuse sp500, clear
by date: egen mean_open = mean(open)
twoway (bar mean_open date in 1/37, color(sand)) (rcap high low date in 1/37, color(ebblue))
如果要定义每个栏的颜色,则需要覆盖多个twoway bar
图形并使用bcolor()
选项,以便获得所需的输出,具体取决于根据您的数据:
twoway (bar mean_open date in 1/37 if date < `= daily("27/01/2001", "DMY")', bcolor(red)) ///
(bar mean_open date in 1/37 if date > `= daily("27/01/2001", "DMY")', bcolor(orange)) ///
(rcap high low date in 1/37, color(black))