你好,
我附加了一個腳本,該腳本生成一個小數據表,其中附加了一個名為“顏色編碼散點圖網格”的JSL 腳本,如果運行該腳本,應該會生成一個圖形生成器輸出,其中顯示每個散佈圖的(2x2) 網格所有點都有不同的顏色和/或符號。
我遇到的問題是,我正在嘗試編寫一個腳本,該腳本允許我將此類圖表中的變數交換為同一資料集中的不同列集,和/或在或上繪製的變數數量X 軸和Y 軸(例如,該範例目前顯示了(2x2) 網格,但我可能想透過在X 軸上新增第三個X 資料列來將其變更為(3x2) 網格)。
我知道如何將“<< 新增變數”和“<< 刪除變數”屬性套用到gb[GraphBuilderBox(1)](其中gb 是圖形產生器物件),以將圖表中的一組變數交換為另一組。 我什麼沒有已經能夠弄清楚的是如何修改對應的Elements語句。 腳本索引中有一個適用於 GraphBuilderBox 顯示框的範例,但其中的“<< Add Element”範例涉及添加擬合線 - 我不知道如何將其與我的問題聯繫起來,其中涉及添加元素具有“位置”和“點”參數。
誰能給我指出一些我可以適應的語法範例?
非常感謝。
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 )
)
我不確定這還有什麼其他影響,但您可以新增和刪除列和行,而無需直接修改元素,只需將變數新增至新位置即可:
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 ) } )
或者,您可以將圖表替換為具有正確數量元素的新圖表:
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 ) ),
)
)
);