運行腳本時顯示圖形你好。 我為我的表創建了一個腳本,我希望當我右鍵單擊“運行腳本”時,它會執行我的腳本並顯示一些圖表。 然而,當我運行我的主要代碼時,圖表會自動顯示,當我右鍵單擊“運行腳本”之後它什麼也不做。 我需要您的幫助來指出我的代碼中的錯誤。 謝謝。
下面是長代碼的一部分。
aGraph = Graph Builder(
Size( xSize, ySize ),
Show Control Panel( 0 ),
Variables( X( :V ), Y( :I ), Overlay( :PID ) ),
Elements( Points( X, Y, Legend( 4 ), Jitter( 1 ) ), Line( X, Y, Legend( 6 ), Row order( 0 ), Summary Statistic( "Mean" ) ) ),
SendToReport(
Dispatch( {}, "ID", ScaleBox, {Scale( "Log" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} ),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 ), Line Width Scale( 0.1 )} )
)
);
bGraph = Graph Builder(
Size( xSize, ySize ),
Show Control Panel( 0 ),
Variables( X( :V ), Y( :I ), Overlay( :PID ) ),
Elements( Points( X, Y, Legend( 3 ), Jitter( 1 ) ), Line( X, Y, Legend( 5 ), Row order( 0 ), Summary Statistic( "Mean" ) ) ),
SendToReport(
Dispatch( {}, "IG", ScaleBox, {Scale( "Linear" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} ),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 ), Line Width Scale( 0.1 )} )
)
);
// Create new script
dt << New Script(
"Plot Graph",
graphWindow = New Window( "Graphs",
Panel Box( "Graphs",
V List Box(
H List Box(
If( !Is Empty( aColumns ),
aGraph
),
If( !Is Empty( bColumns ),
bGraph
)
)
)
)
)
);回复:運行腳本時顯示圖形問題是命名空間之一。嵌入數據表中的腳本在與從腳本窗口運行的腳本不同的內存位置(命名空間)中存儲和獲取內存變量。但是,您可以創建兩個腳本都可以使用的全局命名空間。
因此,如果您的嵌入式腳本中有代碼用於設置指向全局內存空間的大小......假設我們稱該空間為“gspace”,那麼嵌入式腳本中的代碼將是
size(gspace:xSize,gspace:ySize),
你會在你打開的腳本窗口中運行
gspace = new namespace("GSpace");
gspace:xSize = 800;
gspace:ySize = 600;
然後,當您運行嵌入式代碼時,它會找到 gSpace 變量
回复:運行腳本時顯示圖形@txnelson ,
謝謝它的工作。 但是我有一個後續問題……我的腳本中的變量:xSize、ySize、aColumns 和 bColumns 保存新腳本之外的值。 但是,當運行新腳本時,值不會在表達式內部傳遞。 我總是很難使用 Eval 和 Expr。 你能幫我指出如何解決這個問題嗎?
回复:運行腳本時顯示圖形agraph 和 bgraph 代碼需要成為腳本的一部分。下面是一個生成腳本的版本,該腳本將執行您需要的內容。
Names Default To Here( 1 );
dt = Current Data Table();
// Create new script
dt << New Script(
"Plot Graph",
aGraph = Expr(
Graph Builder(
Size( xSize, ySize ),
Show Control Panel( 0 ),
Variables( X( :V ), Y( :I ), Overlay( :PID ) ),
Elements(
Points( X, Y, Legend( 4 ), Jitter( 1 ) ),
Line( X, Y, Legend( 6 ), Row order( 0 ), Summary Statistic( "Mean" ) )
),
SendToReport(
Dispatch(
{},
"ID",
ScaleBox,
{Scale( "Log" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )}
),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 ), Line Width Scale( 0.1 )} )
)
)
);
bGraph = Expr(
Graph Builder(
Size( xSize, ySize ),
Show Control Panel( 0 ),
Variables( X( :V ), Y( :I ), Overlay( :PID ) ),
Elements(
Points( X, Y, Legend( 3 ), Jitter( 1 ) ),
Line( X, Y, Legend( 5 ), Row order( 0 ), Summary Statistic( "Mean" ) )
),
SendToReport(
Dispatch(
{},
"IG",
ScaleBox,
{Scale( "Linear" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )}
),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 ), Line Width Scale( 0.1 )} )
)
)
);
graphWindow = New Window( "Graphs",
Panel Box( "Graphs",
V List Box(
H List Box(
If( !Is Empty( aColumns ),
aGraph
),
If( !Is Empty( bColumns ),
bGraph
)
)
)
)
);
);