我有一个简单的SAS data set我正在绘制散点图,我的两个问题是:
这是我的代码:
proc sgplot data=work.sas1;
title 'Puromycin Uptake Experiments';
scatter x=x y=y/ markerattrs=(color=black);
xaxis Label='Reactant Concentration X (mg/l)';
yaxis Label='Reaction Velocity Y (mg/s)' values=(60 to 160 by 20);
run;
有人可以帮忙吗?
答案 0 :(得分:2)
尝试使用OFFSETMIN=
将y轴扩展到超出您的值。
使用公式的值添加新变量y_hat
。绘制并对其进行适当标记。
data sas1;
x=.02; y=67; output;
x=.02; y=51; output;
x=.06; y=84; output;
x=.06; y=86; output;
x=.11; y=98; output;
x=.11; y=115; output;
x=.22; y=131; output;
x=.22; y=124; output;
x=.56; y=144; output;
x=.56; y=158; output;
x=1.1; y=160; output;
run;
data sas1;
set sas1;
Y_hat=(160.3*x)/(0.0477+x);
run;
proc sgplot data=work.sas1;
title 'Puromycin Uptake Experiments';
scatter x=x y=y/ markerattrs=(color=black);
series x=x y=y_hat / curvelabel="Y=(160.3*x)/(0.0477+x)";
xaxis Label='Reactant Concentration X (mg/l)';
yaxis Label='Reaction Velocity Y (mg/s)' offsetmin=.1 values=(60 to 160 by 20);
run;
答案 1 :(得分:1)
y轴
有几个y轴选项会影响轴渲染。考虑offsetmin
values=
或调整后的列表
公式行
formula
中没有SGPLOT
声明,因此您必须创建一个辅助列,以便在series
中绘制公式。有时您可以将数据的x与公式的x对齐。但是,对于需要更高密度x的公式,您可以堆叠散点图和公式数据。 不要挂在缺失价值观和任何浪费感上。
我不确定曲线拟合的来源,但统计图形(SGPL中的SG)有许多功能可以拟合内置的数据。
* make some example data that looks something like the fit curve;
data have;
do x = 0.03 to 1 by 0.0125;
y = ( 160.3 * x ) / ( 0.0477 + x ) ;
y + round ( 4 * ranuni(123) - 8, 0.0001);
output;
x = x * ( 1 + ranuni(123) );
end;
x = 0.02;
y = 51;
output;
run;
* generate the series data for drawing the fit curve;
* for complicated formula you may want to adjust step during iteration;
data fit;
step = 0.001;
do x = 0 to 1;
y = ( 160.3 * x ) / ( 0.0477 + x ) ;
output;
* step = step + smartly-adjusted-x-increment;
x + step;
end;
keep x y;
rename x=xfit y=yfit;
run;
* stack the scatter data and the curve fit data;
data have_stack_fit;
set have fit;
run;
proc sgplot data=have_stack_fit;
scatter x = x y = y;
series x = xfit y = yfit / legendlabel="( 160.3 * x ) / ( 0.0477 + x )";
yaxis values = (0 60 to 160 by 20) ;
run;