我正在嘗試編寫一個jsl 來繪製x 與y 之間的二元圖,按“b”列中的值進行分組,並在每個組中擬合一條線(來自“b”列中的唯一值) 。從我所做的手動雙變量圖生成的腳本如下,但我無法弄清楚如何為所有遍歷“b”列中的唯一值的“FitWhere”命令添加 for 循環
Bivariate(
Y( :Name( "y" ) ),
X( :Name( "x" ) ),
Automatic Recalc( 1 ),
Fit Where( :p</img> == "grpA", Fit Line( {Line Color( {228, 26, 28} )} ) ),
Fit Where(
:b == "grpB",
Fit Line( {Line Color( {55, 126, 184} )} )
),
Fit Where(
:b == "grpC",
Fit Line( {Line Color( {77, 175, 74} )} )
),
Fit Where(
:b == "grpD",
Fit Line( {Line Color( {152, 78, 163} )} )
),
Fit Where(
:b == "grpE",
Fit Line( {Line Color( {255, 127, 0} )} )
),
Fit Where(
:b == "grpF",
Fit Line( {Line Color( {166, 86, 40} )} )
),
Where( :c == "TT" & :e == "EE" ),
SendToReport(
Dispatch( {}, "1", ScaleBox, {Reversed Scale} ),
Dispatch( {}, "2", ScaleBox, {Reversed Scale} ),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Marker Size( 6 ), Row Legend(
e,
Color( 0 ),
Color Theme( "" ),
Marker( 1 ),
Marker Theme( "Standard" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch( {}, "Linear Fit b==grpA, OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Linear Fit b==grpB", OutlineBox, {Close( 1 )} ),
Dispatch(
{},
"Linear Fit b==grpC",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{},
"Linear Fit b==grpD",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{},
"Linear Fit b==grpE",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{},
"Linear Fit b==grpF",
OutlineBox,
{Close( 1 )}
)
)
);我認為您正在尋找的是 groupby() arg。如果你想指定顏色,那麼在列級別做起來肯定更容易,比如@txnelson說。
Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
biv = dt << Bivariate(
Y( :weight ),
X( :height ),
Group BY(:sex),
Fit line()
);我相信在變量
的列屬性中設置顏色並使用 By() 元素會更容易。
names default to here(1);
:b << set property("value colors",
{"grp8" = {55, 126, 184} }, "grpC" = {77, 175, 74} etc. }
);
Bivariate(
Y( :x ),
X( :y ),
Fit Line( ),<BR /> by( : B )
);Bivariate 平台有自己的 Group By 功能,可從平台菜單或 JSL 獲得:
Names Default to Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
obj = dt << Bivariate(
Y( :weight ),
X( :height )
);
obj
<< Group By( :sex )
<< Fit Line;