グラフボックス: 変数の値は作成後も変化し続けます[JMP 19] In the following script, I am trying to create a series of graph boxes that are displayed below each other in a window. For this i am given a list of values for every important characteristic (these lists are all accessible via the Associative Array 'listMap'. Then I create all graph boxes via a for loop.
This however doesn't work because the variables that are used inside of the Graph Box (i.a. iV, listMap<SPAN class="token punctuation">[</SPAN><SPAN class="token string">「中央値」</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">[</SPAN>iV<SPAN class="token punctuation">]</SPAN>, numReferenceLines) also change the already created Graph Boxes that use them.
Is there a way to fixate the variables in a Graph Box? I want them to be evaluated instantly and then to not be able to be changed.
Disclaimer: According to my trials, 'Eval' doesn't seem to help. Neither do Namespaces (as they also still update, even if locked) or Journals (even if 'Freeze All' is activated).
どのような形でもご協力いただければ幸いです。どうぞよろしくお願いいたします。
ClearGlobals();
NamesDefaultToHere( 1 );
width = 1600;
height = 900;
boxPlotWidth = 0.5;
v = 3;
listMap = Associative Array();
listMap["frameHeightMin"] = {0.5, 0.3, 0.4};
listMap["frameHeightMax"] = {1.5, 2.0, 4.1};
listMap["numReferenceLines"] = {3 , 5 , 8 };
listMap["min"] = {0.6, 0.6, 0.5};
listMap["median"] = {0.9, 1.4, 2.6};
listMap["max"] = {1.3, 1.7, 3.9};
win = New Window("Test");
For(iV = 1, iV <= v, iV++,
numReferenceLines = listMap["numReferenceLines"][iV];
frameHeightMin = listMap["frameHeightMin"][iV];
frameHeightMax = listMap["frameHeightMax"][iV];
win << Graph Box(
Frame Size( width, height ),
X Scale( 0, 2),
Y Scale( frameHeightMin, frameHeightMax ),
X Name("split"),
Y Name("values"),
//[] Generate grey horizontal lines
For(h = 0, h <= numReferenceLines, h++, HLine(frameHeightMin + (h/(numReferenceLines)*(frameHeightMax - frameHeightMin)))),
//[] Min
If(Contains(listMap, "min") & Contains(listMap, "min"),
Line({1 - boxPlotWidth/2, listMap["min"][iV] }, {1 + boxPlotWidth/2, listMap["min"][iV] }));
//[] Median
If(Contains(listMap, "median") & Contains(listMap, "median"),
Line({1 - boxPlotWidth/2, listMap["median"][iV]}, {1 + boxPlotWidth/2, listMap["median"][iV] }));
//[] Max
If(Contains(listMap, "max") & Contains(listMap, "max"),
Line({1 - boxPlotWidth/2, listMap["max"][iV] }, {1 + boxPlotWidth/2, listMap["max"][iV] }));
);
);
自動化とスクリプトデータの探索と可視化Re: グラフボックス: 変数の値は作成後も変化し続けますEvalExpr() または Substitute() のいずれかを Eval() と組み合わせて使用して、グラフ ボックスの値を評価します。
Names Default To Here(1);
width = 1600;
height = 900;
boxPlotWidth = 0.5;
v = 3;
listMap = Associative Array();
listMap["frameHeightMin"] = {0.5, 0.3, 0.4};
listMap["frameHeightMax"] = {1.5, 2.0, 4.1};
listMap["numReferenceLines"] = {3, 5, 8};
listMap["min"] = {0.6, 0.6, 0.5};
listMap["median"] = {0.9, 1.4, 2.6};
listMap["max"] = {1.3, 1.7, 3.9};
win = New Window("Test");
For(iV = 1, iV <= v, iV++,
numReferenceLines = listMap["numReferenceLines"][iV];
frameHeightMin = listMap["frameHeightMin"][iV];
frameHeightMax = listMap["frameHeightMax"][iV];
Eval(EvalExpr(
win << Append(Graph Box(
Frame Size(width, height),
X Scale(0, 2),
Y Scale(frameHeightMin, frameHeightMax),
X Name("split"),
Y Name("values"),
Line({1 - Expr(boxPlotWidth) / 2, Expr(listMap["min"][iV])}, {1 + Expr(boxPlotWidth) / 2, Expr(listMap["min"][iV])});
));
));
);
評価すべき変数がたくさんあるので、代替品を使うのがおそらく良い選択肢でしょう。
Re: グラフボックス:作成後も変数の値が変化し続けるどうもありがとうございます。これで問題なく動作します。ところで、「Graph Box(...)」の中にForLoopが必要な場合にも、何らかの方法で実装できるかどうかご存知でしょうか?以下のコードは、前の例をベースにしていますが、異なるボックスプロットごとにウィンドウごとに複数の値が含まれています。
Names Default To Here(1);
width = 1600;
height = 900;
boxPlotWidth = 0.5;
v = 3; // number of canvas'
n = 2; // number of boxplots per canvas
listMap = Associative Array();
listMap["frameHeightMin"] = {0.5, 0.3, 0.4};
listMap["frameHeightMax"] = {1.5, 2.0, 4.1};
listMap["numReferenceLines"] = {3, 5, 8};
listMap["min"] = {{0.7, 0.6}, {0.4, 0.6}, {0.7, 0.5}};
listMap["median"] = {{0.9, 0.9}, {1.3, 1.4}, {3.0, 2.6}};
listMap["max"] = {{1.4, 1.3}, {1.8, 1.7}, {3.8, 3.9}};
win = New Window("Test");
For(iV = 1, iV <= v, iV++,
numReferenceLines = listMap["numReferenceLines"][iV];
frameHeightMin = listMap["frameHeightMin"][iV];
frameHeightMax = listMap["frameHeightMax"][iV];
Eval(EvalExpr(
win << Append(Graph Box(
Frame Size(width, height),
X Scale(0, n + 1),
Y Scale(frameHeightMin, frameHeightMax),
X Name("split"),
Y Name("values"),
For(iN = 1, iN <= n, iN++,
Line({iN - Expr(boxPlotWidth) / 2, Expr(listMap["min"][iV][iN])}, {iN + Expr(boxPlotWidth) / 2, Expr(listMap["min"][iV][iN])});
Line({iN - Expr(boxPlotWidth) / 2, Expr(listMap["median"][iV][iN])}, {iN + Expr(boxPlotWidth) / 2, Expr(listMap["median"][iV][iN])});
Line({iN - Expr(boxPlotWidth) / 2, Expr(listMap["max"][iV][iN])}, {iN + Expr(boxPlotWidth) / 2, Expr(listMap["max"][iV][iN])});
)
));
));
);
このコードを実行しようとすると、常に「名前が解決されません: 'iN' のアクセスまたは評価で iN が見つかりました 、iN/*###*/名前が解決されません: 'iN' のアクセスまたは評価で iN が見つかりました 、iN/*###*/」というエラーが発生します。
この方法についてもっと詳しい情報をお持ちでしたら、ぜひ教えていただけると大変ありがたいです(:
ところで、Eval、EvalExpr、Exprが実際にどのように動作するのかを知ることができるウェブサイトやフォーラムの投稿などはありますか?
Re: グラフボックス:作成後も変数の値が変化し続ける通常、私はGraphBox内で値を評価し、例えばForループなどで簡単にアクセスできるようにします。 このPDFファイル、 スクリプトガイド、JMP内のスクリプトインデックス、そしてJMPコミュニティは、いずれも非常に優れた情報源です。
これらのことをテストする際には、理解しやすくするためにもっとシンプルなものを実装してみることをお勧めします。
Names Default To Here(1);
width = 1600;
height = 900;
linecount = 3;
linesx = {1, 2, 3};
linesy = {4, 6, 8};
nw = New Window("",
vlb = V List Box();
);
Eval(EvalExpr(
vlb << Append(Graph Box(
Frame Size(width, height),
X Scale(0, 10),
Y Scale(0, 10),
X Name("split"),
Y Name("values"),
ngb = Expr(linecount);
xs = Expr(linesx);
ys = Expr(linesy);
For(i = 1, i <= ngb, i++,
H Line(xs[i]);
V Line(ys[i]);
);
));
));