Hola, soy nuevo en el lenguaje de programación jmp. El siguiente código funciona (muestra gráficos de barras de la columna 3 a n) pero hay una cosa que me gustaría hacer. ¿Cómo hago un script para que mi salida sea un gráfico de barras apiladas de todas las columnas?
for(i=3,i<=NItems(colList2),i++,
gb=dt4 << Generador de gráficos(
Tamaño (534,454),
Mostrar panel de control(0),
variables(
X(:Etiqueta),Y(eval(Columna(dt4,colList2[i]))),
),
Elementos(Barra(X,Y))
));
No hay una sola declaración que se pueda expandir para cubrir un número diferente de columnas Y entrantes.Por lo tanto, debe tomar el formulario básico y crearlo dinámicamente según la cantidad de columnas.
Aquí está la forma básica
Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables(
X( :SITE ),
Y( :NPN1 ),
Y( :PNP1, Position( 1 ) ),
Y( :PNP2, Position( 1 ) ),
Y( :NPN2, Position( 1 ) ),
Y( :PNP3, Position( 1 ) )
),
Elements(
Bar(
X,
Y( 1 ),
Y( 2 ),
Y( 3 ),
Y( 4 ),
Y( 5 ),
Legend( 4 ),
Bar Style( "Stacked" )
)
)
);
Aquí está el script de ejemplo que creé que crea dinámicamente un gráfico de barras apiladas
names default to here(1);
dt=open("$SAMPLE_DATA/Blood Pressure.jmp");
// Get all of the continuous data columns
colList = dt << get column names(continuous,string);
// Create the JSL to create the script
theExpr = "Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables(
X( :Dose ),";
// Add the first Y entry
theExpr = theExpr || "Y( :" || colList[1] || " )";
// Add the remaining Y entries
For( i=2, i<= n items(colList), i++,
theExpr = theExpr || ", Y( :" || colList[i] || ", Position( 1 ) )";
);
// Finish up the Variables list, and start the Elements
theExpr = theExpr || "), Elements( Bar(X, Y( 1 )";
// Add the remaining Y elements
For( i=2, i<= n items(colList), i++,
theExpr = theExpr || ", Y( " || char(i) || " )";
);
// Finish up the required specifications
theExpr = theExpr || ",
Legend( 4 ),
Bar Style( \!"Stacked\!" )
)
)
);";
// Run the created JSL
eval(parse(theExpr));
que produce

¡Gracias por la respuesta! ¿Tiene alguna idea de cómo debo hacerlo para que el script ejecute automáticamente el script en diferentes conjuntos de datos con diferentes nombres de columna sin tener que usar el generador de gráficos de forma interactiva?
@txnelson escribió:
De manera interactiva, vaya a Graph Builder y desarrolle el gráfico para que se vea de la manera que desea que se vea, y luego simplemente vaya al triángulo rojo y seleccione "Guardar secuencia de comandos". JMP crea el JSL para usted.