Graphique : les valeurs des variables continuent de changer même après leur création[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">"médian"</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).
Toute aide est la bienvenue. Merci d'avance !
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] }));
);
);
Automatisation et scriptageExploration et visualisation des donnéesRe : Boîte graphique : les valeurs des variables continuent de changer même après leur créationÉvaluez les valeurs de vos cases de graphique en utilisant soit EvalExpr(), soit Substitute() avec 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])});
));
));
);
Le remplacement est probablement la meilleure option pour vous, étant donné le nombre important de variables à évaluer.
Re : Boîte graphique : les valeurs des variables continuent de changer même après leur créationMerci beaucoup, cela fonctionne parfaitement. Cependant, savez-vous s'il est possible d'implémenter cette méthode en intégrant une boucle `for` dans `Graph Box(...)` ? Le code suivant est basé sur l'exemple précédent, mais il contient désormais plusieurs valeurs par fenêtre pour différents diagrammes en boîte.
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])});
)
));
));
);
Lorsque j'essaie d'exécuter ce code, j'obtiens toujours l'erreur « Nom non résolu : iN lors de l'accès ou de l'évaluation de 'iN', iN/*###*/Nom non résolu : iN lors de l'accès ou de l'évaluation de 'iN', iN/*###*/ ».
Si vous avez plus d'informations sur la façon de procéder, je vous serais très reconnaissant(e) (:
Au fait, existe-t-il un site web, un forum ou autre permettant de comprendre le fonctionnement de Eval, EvalExpr et Expr ?
Re : Boîte graphique : les valeurs des variables continuent de changer même après leur créationEn général, j'évalue les valeurs à l'intérieur de GraphBox pour faciliter leur accès, par exemple pour une boucle For. Ce PDF , le guide de script , l'index des scripts (dans JMP) et la communauté JMP sont d'excellentes ressources.
Je vous suggère également d'essayer de mettre en œuvre quelque chose de beaucoup plus simple lors des tests, afin de faciliter la compréhension.
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]);
);
));
));