檢測圖形標題的圖形腳本我想設置一個自定義圖形腳本,以便每個圖形根據關聯數組中包含的信息獲得一條唯一的線。 在下面的例子中,我想在每個類別的線上有一個不同的圖表......對於我的實際使用,我需要圖表來“識別”它下面的標題,這樣我就可以使用正確的值來創建線.
對於下面的示例圖像,我手動將“F”圖形腳本更新為“F”。 所以我正在尋找“收集圖形信息”的語法......在我的腦海中,如果我可以抓住大綱框標題,我可以操縱它來獲得我需要的東西......但我不確定那是否是唯一/最好的選擇。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = "M";// need to extract so it's "F" for female graph
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);

大規模定制回复:檢測圖形標題的圖形腳本@馬克貝利謝謝你的想法! 很高興知道 summarize 將匹配圖表在報告中的創建順序。 這是我可以在我的幾個腳本中看到的用途 
@Craige_Hales這個功能真是個很酷的主意,我也得試試看!
回复:檢測圖形標題的圖形腳本如果你把整個圖形腳本變成一個函數,它會得到一個這參數即框框。 你可以爬上大綱來抓住標題。 好處是知道你得到的大綱包含這圖形。
Outline title copied into graph by graphic scriptOutline title copied into graph by graphic script通過圖形腳本複製到圖形中的大綱標題
dt = Open( "$sample_data/big class.jmp", invisible );
bv = dt << Bivariate( Y( :weight ), X( :height ), Fit Line );
(bv << report)[framebox( 1 )] << addgraphicsscript(
// if a function is used, it must be the only statement in the graphic script
Function( {this},{titlebox=this},
// the function can use this to find the frame box, climb to an Outline title...
While( (titlebox << classname) != "OutlineBox", titlebox = titlebox << parent );
// then other graphics commands
Text( center justified, {60, 120}, (titlebox << gettitle) );
Circle( {60, 120}, 30 );
this<<BACKGROUNDCOLOR></BACKGROUNDCOLOR>回复:檢測圖形標題的圖形腳本另一種方法可能是在啟動 Bivariate 之前確定這些值。 Summarize() 函數可用於確定級別以相同的順序並且它們在使用 By 變量或 Where() 子句時出現。
Summarize( level = By( :Group ) );
變量 level 以正確的順序在 :Group 數據列中存儲所有唯一級別的字符串列表。 所以你的圖形腳本不需要查詢輪廓顯示框來找出它在哪裡。
回复:檢測圖形標題的圖形腳本那也可以, @jthi ...正如所寫的那樣,它不會像我長期需要的那樣動態,但我可以使用它來構建自定義迭代器變量,因此每個圖都有相同的變量,但設置為不同的數字,對應於它的位置在報告中。
再次感謝大家的想法!
回复:檢測圖形標題的圖形腳本通過以下方式擴展其中一個代碼@txnelson :
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Grid Line Order(1 ), Reference Line Order( 3)}
)
)
);
rep = biv << Get As Report;
For( i = 1, i <= N Items(rep), i++,
keyForAa = Substr(Report(rep [i])[Outline Box( 1 )] << get title,
Contains(Report(rep [i])[Outline Box( 1 )] << get title, "=" ) + 1);
//see Add Graphics Script example from Scripting Index
framebox = Report(rep [i])[frame box(1)];
Eval(EvalExpr(framebox << Add Graphics Script(
2,
Description( "" ),
Y Function(Expr(test[keyForAa][1]) * x + Expr(test[keyForAa][2]), x );
)));
);回复:檢測圖形標題的圖形腳本令人著迷的是你可以從 0 開始 i 並且它就像那樣“神奇地”迭代...... 我在下面粘貼了錯誤,但似乎至少起到了一些作用。 我在創建 graphInfo 變量之前創建了一個 show(i) 命令。
它似乎對這兩個圖很有效,但由於某種原因,它還迭代了兩次,導致無法定位 biv[i] ...所以我將該部分包裝在 Try() 中,它似乎可以作為必要的!
1)我不確定為什麼“i”會這樣迭代,或者我什麼時候可以將它用於 jsl 中的其他功能
2)我不確定為什麼它似乎又重複了兩次......每個圖形一次,每個圖形腳本一次?
3)太感謝了在這裡尋求幫助... 我可能還不明白它是如何/為什麼工作的,但如果我能讓它始終如一地工作,那就是勝利!

Names default to here(1);
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
i=0;
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
i++;
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
show(i);
Try(
graphInfo = word(2,report(biv[i])[OutlineBox(1)] << get title,"=");
show(graphinfo);
);
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);回复:檢測圖形標題的圖形腳本嘗試這個
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
i=0;
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
i++;
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = word(2,report(biv[i])[OutlineBox(1)] << get title,"=");
show(graphinfo);
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);回复:檢測圖形標題的圖形腳本就是這樣....從圖形腳本本身,我能知道那個信息嗎?
從外面獲得稱號很容易。
我希望能夠將完全相同的圖形腳本放入報告的每個圖形中,並讓該腳本能夠找出它的位置。
回复:檢測圖形標題的圖形腳本您將需要知道您需要從哪個大綱框獲取標題,但在那之後,這是一個簡單的獲取標題
graph title = report( biv[1] )[OutlineBox(1)] << get title;
回复:檢測圖形標題的圖形腳本我不是要更新標題,而是要獲取標題信息……從圖形腳本中獲取。 一旦我有了標題信息,我就可以進行所有的字符串操作。
理想情況下,我需要在圖形腳本中放入一些內容,例如“graphTitle = graph << get title;”然後從那裡開始,但我不確定這是可能的,除非對象“知道”它包含在樹的哪一部分中......
回复:檢測圖形標題的圖形腳本這是對您的腳本的修改,將更新標題

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = "M";// need to extract so it's "F" for female graph
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
);
For( i = 1, i <= N Items( biv ), i++,
Report( biv[i] )[Outline Box( 1 )] << set title(
Substr(
Report( biv[i] )[Outline Box( 1 )] << get title,
Contains( Report( biv[i] )[Outline Box( 1 )] << get title, "=" ) + 1
)
)
);