我正在尝试连接两个点来表示以下数据集的置信区间。
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上的标注
发布于 2014-08-21 15:26:05
以下是几个选项:
// 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)

发布于 2014-08-21 15:26:21
这是阅读精致手册的内容。开始于
clear
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
twoway rcap Y_upper_ci Y_lower_ci X || scatter Y X, ytitle(Y) xtitle(X) legend(off) 与rcap相比,有些人更喜欢rspike。我建议使用legend(off),并在为论文提供的插图标题中添加适当的文本。
https://stackoverflow.com/questions/25418099
复制相似问题