Cuadro gráfico: los valores de las variables continúan cambiando incluso después de su creación[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">"mediana"</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).
Agradezco cualquier ayuda. Gracias de antemano.
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] }));
);
);
Automatización y scriptingExploración y visualización de datosRe: Graph Box: los valores de las variables siguen cambiando incluso después de su creaciónEvalúa los valores de tus cuadros gráficos usando 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])});
));
));
);
Lo más probable es que el sustituto sea la mejor opción para usted, ya que tiene muchas variables para evaluar.
Re: Cuadro de gráficos: los valores de las variables siguen cambiando incluso después de su creación.Muchas gracias, esto me funciona perfectamente. Sin embargo, ¿sabes si también se puede implementar de alguna manera si necesito un bucle for dentro de "Graph Box(...)"? El siguiente código se basa en el ejemplo anterior, aunque ahora contiene varios valores por ventana para diferentes diagramas de caja.
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])});
)
));
));
);
Al intentar ejecutar este código, siempre obtengo el error "Nombre sin resolver: iN en el acceso o evaluación de 'iN' , iN/*###*/Nombre sin resolver: iN en el acceso o evaluación de 'iN' , iN/*###*/".
Si sabes más sobre cómo hacer esto, te lo agradecería mucho (:
Por cierto, ¿existe alguna página web o publicación en foros, etc., donde se pueda averiguar cómo funcionan realmente Eval, EvalExpr y Expr?
Re: Cuadro de gráficos: los valores de las variables siguen cambiando incluso después de su creación.Normalmente, evalúo los valores dentro de GraphBox para que sean más fáciles de acceder, por ejemplo, para un bucle For. Este PDF , la Guía de scripting , el Índice de scripting (dentro de JMP) y la comunidad de JMP son fuentes bastante buenas.
También te sugiero que intentes implementar algo mucho más sencillo al probar estas cosas para que sean más fáciles de entender.
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]);
);
));
));