标签: graph bar-chart stata
请考虑以下代码和数据示例:
sysuse auto, clear drop if rep78 == . | rep78 == 3 recode rep78 (4 = 3) (5 = 4) collapse price, by(rep78) twoway bar price rep78, barwidth(0.2)
如何用不同的颜色照亮绘图中的特定条(例如第二条)?
答案 0 :(得分:2)
使用twoway图形,您可以通过叠加如下所示的新条形图来产生所需的效果:
twoway
twoway (bar price rep78, barwidth(0.2)) /// (bar price rep78 if rep78 == 2, barwidth(0.2) color(red))
或者:
separate price, by(rep78) twoway bar price? rep78, barwidth(0.2 0.2 0.2 0.2) color(navy red navy navy)
两者都会产生相同的结果: