안녕하세요 여러분
저는 열 목록이 크고, 이를 반복하여 열 목록의 모든 열에 대해 이변량 차트를 만듭니다. 제 x축은 항상 동일하게 유지됩니다.
저는 같은 범주 열로 그룹화하고 있습니다. 하지만 그 열의 그룹/범주 수는 매번 바뀝니다.
각 열에 대한 범주의 개수를 모를 때, 이변량 그래프에서 "적합 위치" 기능을 어떻게 사용하여 모든 범주를 하나의 그래프로 볼 수 있을까요?
일반적으로 나는 내가 원하는 것을 만들기 위해 이렇게 합니다.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Fishing.jmp" );
bivNew = dt << Bivariate(
Y( :Fish Caught ),
X( :People ),
Automatic Recalc( 1 ),
Fit Where( :Validation == 1, Fit Spline( 1, {Line Color( {212, 73, 88} )} ) ),
Fit Where( :Validation == 2, Fit Spline( 1, {Line Color( {66, 112, 221} )} ) )
);
하지만 여기서는 검증 열의 각 범주에 대한 그룹화(Fit Where)를 하드 코딩했습니다. 자동화된 솔루션을 스크립팅하는 측면에서 검증 열에 몇 개의 범주가 있는지 모르는 경우 어떻게 동일한 출력을 얻을 수 있습니까?
도움을 주시면 감사하겠습니다.
여기에 작동할 수 있는 한 가지 방법이 있습니다. 저는 개인적으로 JMP의 기본 제공 스플라인을 사용하지 않습니다. 추가된 제어 상자로 인해 시각적 혼란이 너무 많이 발생하기 때문입니다.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Fishing.jmp" );
Try( dt << Delete Columns( "GROUPING" ) );
dt << New Column( "GROUPING", "Character",
<<SET each="" value=""></SET>
이를 수행하는 방법은 여러 가지가 있지만 가장 간단한 방법 중 하나는 관련 기능을 보유하는 작은 네임스페이스를 사용하는 것입니다.
다음은 기능/기본 설정을 보유하는 라이브러리입니다.
New Namespace( "bivar" );
bivar:default settings = [=>];
bivar:default settings["x size"] = 600;
bivar:default settings["y size"] = 400;
bivar:default settings["lambda"] = 1;
bivar:default settings["standardize splines"] = 1;
bivar:default settings["unselected line width"] = 4;
bivar:default settings["line width"] = 4;
bivar:default settings["selected line width"] = 5;
bivar:default settings["marker size"] = 4;
bivar:default settings["outline lines"] = 1;
bivar:default settings["fade unselected lines"] = 1;
bivar:default settings["spline points"] = 128;
<BR /><BR />//this is the only function that a user needs to call
bivar:plot = Function( {table, x column, y column, categorical column, title = "", settings = bivar:default settings},
{Default Local},
columns = table << Get Column Names();
If( Not( Contains( columns, As Name( x column ) ) ),
Throw( "Unable to find column \!"" || x column || "\!"" );
);
If( Not( Contains( columns, As Name( y column ) ) ),
Throw( "Unable to find column \!"" || y column || "\!"" );
);
If( Not( Contains( columns, As Name( categorical column ) ) ),
Throw( "Unable to find column \!"" || categorical column || "\!"" );
);
If( Column( table, x column ) << Get Data Type != "Numeric",
Throw( "X column must be Numeric" );
);
If( Column( table, y column ) << Get Data Type != "Numeric",
Throw( "Y column must be Numeric" );
);
If( Column( table, categorical column ) << Get Data Type != "Character",
Throw( "Legend column must be Character" );
);
table << Color or Mark by Column( categorical column );
olb = Outline Box( "",
Platform( table,
Bivariate(
X( Column( table, x column ) ),
Y( Column( table, y column ) ),
Dispatch(
{}, "Bivar Plot", Frame Box,
{
Frame Size( settings["x size"], settings["y size"] ), Marker Size( settings["marker size"] )
,
Row Legend( Column( table, categorical column ), Marker( 1 ), Continuous Scale( 0 ), Reverse Scale( 0 ), Excluded Rows( 0 ) )
}
)
)
)
);
If( title != "",
olb[Outline Box( 2 )] << Set Title( title )
);
bivar:add splines( table, olb[Frame Box( 1 )], olb[String Col Box( 1 )], x column, y column, categorical column, settings );
olb
);
bivar:add splines = Function( {table, frame box, legend box, x column, y column, categorical column, settings = bivar:default settings},
{Default Local},
sub table = table << Summary( Group( categorical column ), Link to Original Data Table( 0 ), Private );
colors = [=>];
For Each Row( sub table,
colors[Column( 1 )[]] = Color Of( Row State() )
);
legend values = Column( sub table, 1 ) << Get Values;
Close( sub table, No Save );
splines = [=>];
splines["__items__"] = legend values;
splines["__settings__"] = settings;
splines["__colors__"] = colors;
Summation( i = 1, N Items( legend values ),
item = legend values[i];
splines[item] = [=>];
Eval( Parse( Eval Insert( JSL Quote(
rows = table << Get Rows Where( !Excluded( Row State() ) & :Name("^categorical column^") == "^item^" & !Is Missing( :Name("^x column^") ) & !Is Missing( :Name("^y column^") ) )
) ) ) );
ordinate = Column( table, y column )[rows];
abcissa = Column( table, x column )[rows];
If( N Rows( rows ) > 3 & Min( abcissa ) != Max( abcissa ),
If( settings["standardize splines"],
x mean = Mean( abcissa );
x std dev = Std Dev( abcissa );
abcissa = (abcissa - x mean) / x std dev
);
x values = Min( abcissa )::Max( abcissa )::((Max( abcissa ) - Min( abcissa )) / settings["spline points"]);
spline values = Spline Eval( x values, Spline Coef( abcissa, ordinate, settings["lambda"] ) );
If( settings["standardize splines"],
x values = x std dev * x values + x mean
);
,
x values = abcissa;
spline values = ordinate
);
splines[item]["x"] = x values;
splines[item]["y"] = spline values;
;0
);
Eval( Eval Expr(
frame box << Add Graphics Script(
"CUSTOM_SPLINES";
Local( {splines = Expr( splines ), legend = Expr( legend box ), settings = Expr( settings ), selected, i, items, item, selected items},
selected = legend << Get Selected Rows;
If( N Rows( selected ) == 0,
Summation( i = 1, N Items( splines["__items__"] ),
item = splines["__items__"][i];
Transparency( 1 );
If( splines["__settings__"]["outline lines"],
Pen Color( "Black" );
Pen Size( splines["__settings__"]["line width"] + 1 );
Line( splines[item]["x"], splines[item]["y"] )
);
Pen Color( splines["__colors__"][item] );
Pen Size( splines["__settings__"]["line width"] );
Line( splines[item]["x"], splines[item]["y"] );
;0
)
,
selected items = splines["__items__"][selected];
Summation( i = 1, N Items( splines["__items__"] ),
item = splines["__items__"][i];
If( Not( Contains( selected items, item ) ),
If( settings["fade unselected lines"],
Transparency( 1 - Arg( Arg( Get Preferences( Graph Marker Unselected Fade ), 1 ), 1 ) / 100 )
,
Transparency( 1 )
);
Pen Color( splines["__colors__"][item] );
Pen Size( splines["__settings__"]["unselected line width"] );
Line( splines[item]["x"], splines[item]["y"] );
);
;0
);
Summation( i = 1, N Items( splines["__items__"] ),
item = splines["__items__"][i];
If( Contains( selected items, item ),
Transparency( 1 );
If( splines["__settings__"]["outline lines"],
Pen Color( "Black" );
Pen Size( splines["__settings__"]["selected line width"] + 1 );
Line( splines[item]["x"], splines[item]["y"] )
);
Pen Color( splines["__colors__"][item] );
Pen Size( splines["__settings__"]["selected line width"] );
Line( splines[item]["x"], splines[item]["y"] );
);
;0
)
);
items = splines["__items__"]
)
)
) )
);
0라이브러리가 적어도 한 번 실행된 후에는(예를 들어 추가 기능의 시작 스크립트에 추가) 매우 쉽게 사용할 수 있습니다.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Reliability/Adhesive Bond.jmp" );
dt3 = Open( "$SAMPLE_DATA/Cars.jmp" );
settings = bivar:default settings;
settings["outline lines"] = 0;
New Window( "test",
V List Box(
bivar:plot( dt3, "year", "wt", "make" )
,
bivar:plot( dt3, "year", "wt", "make", "Custom Title", settings ) // show how to change settings
,
bivar:plot( dt, "Height", "weight", "sex" )
,
bivar:plot( dt2, "weeks", "strength", "censor" )
)
)
이제 귀찮은 컨트롤 상자가 없으며 마커의 선택 모드와 일치하도록 만들었습니다("선택되지 않은 페이드" 마커 선택 모드가 있다고 가정).

도움이 되었기를 바랍니다.
이것에 대해 정말 감사합니다. 정말 유용하네요.
하지만 이 함수는 단일 x 및 y 열에 대해 작동하는 듯하고 동일한 x 및 그룹화 열이 있는 y 열 목록을 전달할 때는 작동하지 않습니다. 열 그룹에 대해 작동하도록 업데이트해야 합니다.
이 문제에 대한 도움에 다시 한번 감사드립니다.