I am trying to connect two dots to represent a confidence interval of the following dataset.
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
I have been using the following.
twoway scatter Y Y_upper_ci Y_lower_ci X, ///
connect(l) sort ///
title("Main Title") ///
subtitle("Subtitle") ///
ytitle(Y) ///
xtitle(X)
I thought connect(l)
would take care of this, but it only connects the Y and not the Y_upper_ci
to the Y_lower_ci
.
Also, how can I have the legend only return the label on Y
and not Y_upper_ci
and Y_lower_ci
?
Here are several options:
// 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] 삭제
몇 마디 만하겠습니다