首页 > 解决方案 > 如何在 x 轴值的特定范围内绘制 yline?

问题描述

你能帮我确定我可以在 1991 到 1995 的范围内绘制 yline(对应于值 21)然后在 1996 到 2000 的范围内绘制值为 10 的 yline 的方式吗?下面我附上我到目前为止的代码:

serrbar mean error year , scale(2) addplot(line mean year) xscale(r(1995 2000)) title("xxx")  yaxis(1 
2) xtitle("Year",height(6)) ytitle("xx") legend(order( 1 "xx" 2 "xx"))  xline(1995, lcol(red)) 
yline(21,  lpatter(dash)) yline(10,  lpatter(dash)) xlabel(1991(1)2000)

标签: graphstata

解决方案


你不能这样做,但你可以得到同样的效果。

您没有提供可重现的示例,所以这里有一个。

webuse assembly, clear
serrbar mean std date
serrbar mean std date , addplot(function first=180, ra(108 110) || function second=200, ra(113 116)) legend(order(1 2))

推荐阅读