テーマ形式に式を使用する複数の類似したプロットのフォーマットを式にしようとしているので、コードの1つのセクションを変更して、類似しているすべてのプロットを更新できます。 しかし、私はそれをコードに実装するのに苦労しています。 プロットをどのように見せたいか、コードをどのように見せたいかを示す最小限の作業例を含め、フォーマット用のコードと各プロット用のコンパクトなコードを保存します。 これを変更して機能させる方法についてのアイデアはありますか? 私はJMPバージョン15.2に取り組んでいます。
dt = New Table( "Minimal Working Example",
Add Rows( 400 ),
New Column( "X", Numeric, Set Values( Repeat( 1 :: 20, 20 ) ) ),
New Column( "Y", Numeric, Set Values( Sort Ascending( Shape( Repeat( 1 :: 20, 20 ), 1 ) ) ) ),
New Column( "Size", Numeric, <<FORMULA></FORMULA>
グラフィックススクリプティングRe:テーマフォーマットに式を使用するこんにちは、
式の処理は強力で、少し練習が必要です。 これは開始するための例ですが、Eval()、Expr()、NameExpr()、Substitute()、Substitute Into()などについて読みたいと思うでしょう。
Names Default To Here(1);
//make a 5-column table
dt = astable((1::20)` || J(20,4,randominteger(0,20)));
//the x column will be the first column
xCol = column (dt, 1);
//the y columns will be the remaining columns
yColList = (dt << get column names())[2::ncol(dt)];
//write the graph builder script, wrapping it in an expression. Use _XXX_ format for things
//you'll be substituting later. Here, that is just the "y" variable for a particular graph.
gbExpr = expr(
dt << Graph Builder(
Variables( X( xcol ), Y( _Y_ ) ),
Elements( Points( X, Y, Legend( 8 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
8,
Properties(
0,
{gradient( {Color Theme( "White to Red" )} )},
Item ID( "Size", 1 )
)
)}
),
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {8, [0, -1]} ), Legend Position( {0, -1} )}
)
)
);
);
//cycling through the items in yColList, we create a graph for each y variable vs the x variable.
//be sure to read up on Name Expr ( ), as it is needed here to prevent evaluation of the Graph
//Builder script... we just want the code itself... we don't want JMP to try to evaluate the code
//until after we've made the substitution.
for (i = 1,i <=nitems(ycolList), i++,
eval(Substitute( nameExpr(gbExpr), expr(_Y_) , expr(yColList[i])));
);
乾杯、
ブレイディ
Re:テーマフォーマットに式を使用するX、Y、およびColor変数がデータでどのように変化するかにより、これはうまく機能しませんでしたが、JSL Quote、Eval Insert、Parse、およびEvalを使用して、必要なものに近い解決策を見つけることができました。
// A theme format I could change for a gazillion of plots
formats = JSL Quote(
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
8,
Properties(
0,
{gradient( {Color Theme( "White to Red" )} )},
Item ID( "Size", 1 )
)
)}
),
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {8, [0, -1]} ), Position( {0, -1} )}
)
)
);
// How I would like each plot code to look like
Eval(Parse(Eval Insert("dt << Graph Builder(
Variables( X( :X ), Y( :Y ), Color( :Size ) ),
Elements( Points( X, Y, Legend( 8 ) ) ),
^formats^
);")));