CIAO,
Allego uno script che genera una piccola tabella di dati con uno script JSL allegato chiamato "Grid of Color-Coded Scatter Plots", che se eseguito dovrebbe produrre un output del Graph Builder che mostra una griglia (2x2) di grafici a dispersione in ciascuno dei quali a tutti i punti vengono assegnati colori e/o simboli diversi.
Il problema che ho è che sto cercando di scrivere uno script che mi permetta di scambiare le variabili in un grafico di questo tipo con un diverso insieme di colonne all'interno dello stesso set di dati e/o il numero di variabili tracciate su uno o l'altro entrambi gli assi X e Y (ad esempio l'esempio attualmente mostra una griglia (2x2), ma potrei voler cambiarla in una griglia (3x2) aggiungendo una terza colonna di dati X sull'asse X).
So come applicare le proprietà "<< Aggiungi variabile" e "<< Rimuovi variabile" a gb[GraphBuilderBox(1)], dove gb è l'oggetto del Costruttore di grafici, per scambiare un set di variabili nel grafico con un altro set. Cosa io non l'ho fatto riuscito a capire è come modificare le istruzioni Elements corrispondenti. C'è un esempio nello Scripting Index che si applica alla casella di visualizzazione GraphBuilderBox, ma l'esempio "<< Aggiungi elemento" si riferisce all'aggiunta di una linea adattata e non riesco a vedere come collegarlo al mio problema, che implica l'aggiunta di elementi con i parametri "Posizione" e "Punti".
Qualcuno può indicarmi alcuni esempi della sintassi che potrei essere in grado di adattare?
Grazie molto.
New Table( "JMP Script Demo",
Add Rows( 4 ),
Compress File When Saved( 1 ),
New Script("Grid of Color-Coded Scatter Plots",
Graph Builder(
Size( 713, 469 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Grid Color( "White" ),
Graph Spacing( 10 ),
Spacing Borders( 1 ),
Variables(
X( :X1 ),
X( :X2 ),
Y( :Y3A ),
Y( :Y3B, Position( 1 ) ),
Y( :Y3C, Position( 1 ) ),
Y( :Y3D, Position( 1 ) ),
Y( :Y2A ),
Y( :Y2B, Position( 2 ) ),
Y( :Y2C, Position( 2 ) ),
Y( :Y2D, Position( 2 ) )
),
Elements( Position( 1, 1 ), Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 73 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 78 ) ) ),
Elements( Position( 2, 1 ), Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 77 ) ) ),
Elements( Position( 2, 2 ), Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 79 ) ) ),
SendToReport(
Dispatch( {}, "X1", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "X2", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "Y3A", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch( {}, "Y2A", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
73,
Properties( 0, {Line Color( 3 ), Marker( "Filled Diamond" )} ),
Properties( 1, {Line Color( 36 ), Marker( "FilledCircle" )} ),
Properties( 2, {Line Color( 5 ), Marker( "Square" )} ),
Properties( 3, {Line Color( 8 ), Marker( "FilledCircle" )} )
), Legend Model(
78,
Properties( 0, {Line Color( 3 ), Marker( "Filled Diamond" )} ),
Properties( 1, {Line Color( 36 ), Marker( "FilledCircle" )} ),
Properties( 2, {Line Color( 5 ), Marker( "Square" )} ),
Properties( 3, {Line Color( 8 ), Marker( "FilledCircle" )} )
), Legend Model(
77,
Base( 0, 0, 0 ),
Base( 1, 0, 1 ),
Base( 2, 0, 2 ),
Base( 3, 0, 3 ),
Properties( 0, {Line Color( 3 ), Marker( "Filled Diamond" )} ),
Properties( 1, {Line Color( 36 ), Marker( "FilledCircle" )} ),
Properties( 2, {Line Color( 5 ), Marker( "Square" )} ),
Properties( 3, {Line Color( 8 ), Marker( "FilledCircle" )} )
), Legend Model(
79,
Properties( 0, {Line Color( 3 ), Marker( "Filled Diamond" )} ),
Properties( 1, {Line Color( 36 ), Marker( "FilledCircle" )} ),
Properties( 2, {Line Color( 5 ), Marker( "Square" )} ),
Properties( 3, {Line Color( 8 ), Marker( "FilledCircle" )} )
)}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Grid of Color-Coded Scatter Plots" )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Y3A, Y3B, Y3C & Y3D" )} ),
Dispatch( {}, "Y 1 title", TextEditBox, {Set Text( "Y2A, Y2B, Y2C & Y2D" )} )
)
)
),
New Column( "Sample",
Character( 24 ),
"Nominal",
Set Values( {"Sample A", "Sample B", "Sample C", "Sample D"} )
),
New Column( "X1",
Numeric,
"Continuous",
Format( "Fixed Dec", 10, 2 ),
Set Values( [6.14, 5.14, 6.64, 6.72] )
),
New Column( "X2",
Numeric,
"Continuous",
Format( "Fixed Dec", 10, 2 ),
Set Values( [4.62, 4.52, 4.66, 4.84] )
),
New Column( "X3",
Numeric,
"Continuous",
Format( "Fixed Dec", 10, 2 ),
Set Values( [2.17, 2.52, 3.48, 2.25] )
),
New Column( "Y1A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [6.14, ., ., .] ) ),
New Column( "Y1B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., 5.14, ., .] ) ),
New Column( "Y1C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., 6.64, .] ) ),
New Column( "Y1D", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., ., 6.72] ) ),
New Column( "Y2A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [4.62, ., ., .] ) ),
New Column( "Y2B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., 4.52, ., .] ) ),
New Column( "Y2C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., 4.66, .] ) ),
New Column( "Y2D", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., ., 4.84] ) ),
New Column( "Y3A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2.17, ., ., .] ) ),
New Column( "Y3B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., 2.52, ., .] ) ),
New Column( "Y3C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., 3.48, .] ) ),
New Column( "Y3D", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., ., 2.25] ) ),
Set Row States( [8, 8, 8, 8] ),
Set Label Columns( :Sample )
)
Non sono sicuro di quali altre implicazioni ciò abbia, ma puoi aggiungere e rimuovere colonne e righe senza modificare direttamente gli Elementi, basta aggiungere variabili a nuove posizioni:
gb = Graph Builder(
Size( 713, 469 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Grid Color( "White" ),
Graph Spacing( 10 ),
Spacing Borders( 1 ),
Variables(
X( :X1 ),
X( :X2 ),
Y( :Y3A, Position( 1 ) ),
Y( :Y3B, Position( 2 ) ),
)
);
gbb = Report( gb )[Graph Builder Box( 1 )];
gbb << Add Variable( { :Y3C, Role( "Y" ), Position( 3 ) } );
gbb << Remove Variable( {:Y3A, Role( "Y" ), Position( 1 ) } )
In alternativa, potresti semplicemente sostituire il grafico con uno nuovo con il numero corretto di elementi:
New Window( "Graph",
lb = H list box(
gb = Graph Builder(
Size( 713, 469 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Grid Color( "White" ),
Graph Spacing( 10 ),
Spacing Borders( 1 ),
Variables(
X( :X1 ),
X( :X2 ),
Y( :Y3A, Position( 1 ) ),
Y( :Y3B, Position( 2 ) ),
)
)
);
);
Try( gb << Delete );
lb << Append(
gb = Graph Builder(
Size( 713, 469 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Grid Color( "White" ),
Graph Spacing( 10 ),
Spacing Borders( 1 ),
Variables(
X( :X1 ),
X( :X2 ),
Y( :Y3A, Position( 1 ) ),
Y( :Y3C, Position( 2 ) ),
)
)
);