Graph 无端点连接的Stata双向线图

Graph 无端点连接的Stata双向线图,graph,line,stata,Graph,Line,Stata,对于两个变量,我有两个国家 每个国家数据集的末端不应该与另一个国家数据的起点相连——我不知道如何防止这种行为 twoway (line bspDiff Year if Countryshort == "China" | Countryshort == "India") (line hdiDiff Year if Countryshort == "China" | Countryshort == "India", xlabel(1980(1)2013, labsize(tiny))) 由于只有两

对于两个变量,我有两个国家

每个国家数据集的末端不应该与另一个国家数据的起点相连——我不知道如何防止这种行为

twoway (line bspDiff Year if Countryshort == "China" | Countryshort == "India") (line hdiDiff Year if Countryshort == "China" | Countryshort == "India", xlabel(1980(1)2013, labsize(tiny)))

由于只有两个国家,因此值得使用少量额外代码使行看起来不同:

twoway line bspDiff Year if Countryshort == "China", lc(blue)  || line bspDiff year if  Countryshort == "India", lc(red) || line hdiDiff Year if Countryshort == "China", lc(blue) lp(dash) || line hdiDiff Year if Countryshort == "India", lc(red) lp(dash) xlabel(1980(5)2010) xtick(1980/2013)
在我使用
| |
而不是
()
语法时,除了个人风格偏好之外,没有什么重要的东西

我添加了标记选项,以显示如何控制线条颜色和图案

侧面细节:一个传奇出现在
graph
这样的调用中。编辑默认文本或完全抑制图例是一个趣味问题。图表上适当位置的“中国”或“印度”等文字通常比图例要好得多

我已经编辑了标记x轴的代码。这又是一个品味的问题,但暗示读者不能轻易插入来识别特定年份,这有点侮辱了读者的智慧

这里主要问题的一个简短回答是,尝试使用合适的排序顺序(例如,
sort country short year
)连接(L),以确保当且仅当x轴变量增加时才存在连接。对于不再需要的单独面板,使用单独的线

非常感谢-排序(Countryshort Year)连接(L)-不再有线路端连接!