我试图连接两个点以表示以下数据集的置信区间。
Y Y_upper_ci Y_lower_ci X
10 12 8 1
20 22 14 2
30 37 22 3
40 42 33 4
50 53 48 5
我一直在使用以下内容。
twoway scatter Y Y_upper_ci Y_lower_ci X, ///
connect(l) sort ///
title("Main Title") ///
subtitle("Subtitle") ///
ytitle(Y) ///
xtitle(X)
我以为connect(l)
会照顾这,但它只有Y,而不是连接Y_upper_ci
到Y_lower_ci
。
另外,我如何让图例仅返回标签Y
,而不返回Y_upper_ci
和Y_lower_ci
?
以下是几个选项:
// prepare some data
clear all
input Y Y_upper_ci Y_lower_ci X
10 12 8 1
20 22 14 2
30 37 22 3
40 42 33 4
50 53 48 5
end
// first graph
twoway rcap Y_upper_ci Y_lower_ci X, lstyle(ci) || ///
scatter Y X, mstyle(p1) ///
legend(order(2 "Y" )) ///
note("with 95% confidence interval") ///
name(rcap, replace)
// second graph
twoway rspike Y_upper_ci Y_lower_ci X, lstyle(ci) || ///
scatter Y X, mstyle(p1) ///
legend(order(2 "Y" )) ///
note("with 95% confidence interval") ///
name(rspike, replace)
/// third graph
twoway rline Y_upper_ci Y_lower_ci X, lstyle(ci) || ///
scatter Y X, mstyle(p1) ///
legend(order(2 "Y" )) ///
note("with 95% confidence interval") ///
name(rline, replace)
// fourth graph
twoway line Y_upper_ci Y_lower_ci X, lstyle(p2 p3) || ///
scatter Y X, mstyle(p1) ///
legend(order(3 "Y" )) ///
note("with 95% confidence interval") ///
name(line, replace)
// fifth graph
twoway rarea Y_upper_ci Y_lower_ci X , astyle(ci) || ///
scatter Y X, mstyle(p1) ///
legend(order(2 "Y" )) ///
note("with 95% confidence interval") ///
name(rarea, replace)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句