Graph Box: i valori delle variabili continuano a cambiare anche dopo la creazione[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">"mediano"</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).
Qualsiasi tipo di aiuto è ben accetto. Grazie in anticipo (:
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] }));
);
);
Automazione e scriptingEsplorazione e visualizzazione dei datiRe: Graph Box: i valori delle variabili continuano a cambiare anche dopo la creazioneValuta i valori nelle caselle del tuo grafico utilizzando EvalExpr() o Substitute() con 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])});
));
));
);
Sostituto è probabilmente l'opzione migliore per te, poiché hai così tante variabili da valutare
Oggetto: Riquadro grafico: i valori delle variabili continuano a cambiare anche dopo la creazioneGrazie mille, per me funziona benissimo. Tuttavia, sai se è possibile implementare una soluzione simile anche nel caso in cui avessi bisogno di un ciclo ForLoop all'interno del "Graph Box(...)"? Il codice seguente si basa sull'esempio precedente, anche se ora contiene più valori per finestra per diversi boxplot.
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])});
)
));
));
);
Quando provo a eseguire questo codice, ricevo sempre l'errore "Nome non risolto: iN nell'accesso o nella valutazione di 'iN', iN/*###*/Nome non risolto: iN nell'accesso o nella valutazione di 'iN', iN/*###*/".
Se sai di più su come fare questo, te ne sarei molto grato (:
A proposito, esiste qualche sito web o discussione su forum dove si possa scoprire come funzionano effettivamente Eval, EvalExpr ed Expr?
Oggetto: Riquadro grafico: i valori delle variabili continuano a cambiare anche dopo la creazioneSolitamente valuto i valori all'interno di GraphBox per poterli consultare più facilmente, ad esempio per un ciclo For. Questo PDF , la Guida allo scripting , l'Indice di scripting (all'interno di JMP) e la community di JMP sono tutte ottime fonti.
Suggerirei inoltre di provare a implementare qualcosa di molto più semplice quando si testano queste cose, per renderle più facili da comprendere.
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]);
);
));
));