將圖表保存為 PNG 或 JPEG你好,
我製作了一個腳本,讓用戶選擇一個 Excel 文件,處理它,添加或製定列,打開圖形生成器並使用本地數據過濾器繪製它。
我的問題是:
1. 如何使用腳本選擇本地數據過濾選項來保存圖形? 例如,我有 2 個本地數據過濾器,例如 Trimset(10, 100, 101, 110, 111, 1000, 11111) 和公式(是或否),我需要繪製類似的圖表(所有帶有公式 NO 的修剪集值)和(每個修剪集值都用公式YES)..所以總共8張圖。
2. 在我的圖表中,我希望包含圖表下方的語句“Trimset is .... and Formula is NO”。
3. 將圖形以 png 或 jpeg 文件保存在文件夾中
4.JMP 數據表和圖形生成器表退出而不保存。
5. 由於我需要對 100 個或更多文件執行此操作,因此如何製作插件功能以使其成為單擊操作?
我已經閱讀了所有討論,但無法得到正確的答案。 我真的很感謝你的幫助。
謝謝
回复:將圖表另存為 PNG 或 JPEG是的,可以使用 For 循環。JSL 是一種非常完整的語言,具有計算機語言所期望的所有功能。
我建議您閱讀腳本指南的前幾章,這樣您就可以了解該語言的所有組件以及如何實現它們。
如果您能給我一些有關您使用的計算機語言的信息,這將有助於我以您熟悉的方式為您提供 JSL 示例。
回复:將圖表另存為 PNG 或 JPEG謝謝 txnelson 的回复。 這非常有用。 如果我想在數據過濾器中執行 for 循環,可以嗎? 它可以自動檢查每個條件並繪製圖表。 正如您所建議的,我將研究腳本指南中的插件功能。回复:將圖表另存為 PNG 或 JPEG這是一種不使用數據過濾器的不同方法:
dt = Open( "$sample_data/big class.jmp" );
ages = Data Table( "big class" ) << Summary( Group( :age ), Freq( "None" ), Weight( "None" ) );
sexes = Data Table( "big class" ) << Summary( Group( :sex ), Freq( "None" ), Weight( "None" ) );
deletedirectory("$temp/myPics");
createDirectory("$temp/myPics");
For( iage = 1, iage <= N Rows( ages ), iage++,
thisAge = ages:age[iage];
For( isex = 1, isex <= N Rows( sexes ), isex++,
thisSex = sexes:sex[isex];
eval(evalexpr(biv = dt << Bivariate(
Y( :weight ),
X( :height ),
Automatic Recalc( 1 ),
Fit Line( {Line Color( {213, 72, 87} )} ),
where( age == expr(thisAge) & sex == expr(thisSex) )
)));
parentBox = Report( biv ) << parent;
picture = parentBox << getpicture;
picture << saveImage( "$temp/myPics/age" || Char( thisAge ) || "sex" || Char( thisSex ) || ".png", "png" );
// optional: Open( "$temp/age" || Char( thisAge ) || "sex" || Char( thisSex ) || ".png" );
biv<<CLOSEWINDOW></CLOSEWINDOW>
Files In Directory("$temp/myPics") = {"age12sexF.png", "age12sexM.png", "age13sexF.png", "age13sexM.png", "age14sexF.png", "age14sexM.png", "age15sexF.png", "age15sexM.png", "age16sexF.png", "age16sexM.png", "age17sexF.png", "age17sexM.png"};
where clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graphwhere clause above graph圖表上方的 where 子句
在本例中,where 子句位於平台輸出之上,因此我使用 <回复:將圖表另存為 PNG 或 JPEG
我的第一點是,您不應該閱讀討論來學習如何編寫 JMP 腳本。您應該閱讀 JSL 腳本指南。
幫助==>書籍==>腳本指南
如果您無法解決問題,那麼討論社區是一個很好的資源來幫助您。
讓我來看看你問的問題。
1.如何使用本地數據過濾器,然後保存輸出。
下面是一個粗略的腳本,將向您展示如何以一種非常奇特的方式執行此操作
dt=Open(<PATH to="" your="" data="https://community.jmp.com/" table="">);
gb=Graph Builder(
Size( 527, 453 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 13 ) ), Smoother( X, Y, Legend( 14 ) ) )
);
Thefilter=gb<<LOCAL data="https://community.jmp.com/" filter=""></LOCAL></PATH>
圖形生成器和每個本地過濾器的代碼位於紅色三角形下方。如果您選擇它們並轉到“保存腳本”,您將獲得不同情況所需的代碼。只需啟動圖形生成器即可。然後保存圖形生成器的腳本。然後打開本地過濾器。將其設置為您的第一個案例(where 子句),然後保存它的腳本。接下來,將本地過濾器更改為下一個案例並保存其腳本......等等。
2.圖表下方的語句保存到png中
3. 您只需在保存圖片功能中指定路徑即可。這可以通過編程方式處理,以便它可以遵循您想要使用的任何命名方法。
4. 示例腳本展示了執行此操作的方法
5. 腳本指南中有關於如何製作插件的非常好的文檔。這是一個太長的答案,無法在討論中處理
回覆:將圖表儲存為 PNG 或 JPEG此程式碼會為任何資料過濾器新增一個小選單- 選擇您的列並按一下「確定」以循環瀏覽條目並自動儲存 GraphBuilder 繪圖。
(具有連續值的列不列出)

Names Default to HERE(1);
if(not(namespaceExists("autoAnimate")),New NameSpace("autoAnimate"));
autoAnimate:update = function({},
Try (autoAnimate:DFTopLB = Current Report()["Local Data Filter", List Box( 1 )], stop());
Try(autoAnimate:myDFTPBs = (Current Report()["Local Data Filter", Lineup Ruler Box( 1 ), List Box( 1 )] << Xpath( "//TabPageBox" )),stop());
// collect Data Fitlers with ListBoxes, remove the continuos ones.
autoAnimate:myDFLBs ={};
For Each ( {TPB,i}, autoAnimate:myDFTPBs, tmp=(TPB << xpath( "//ListBoxBox" ));If(NItems(tmp),Insert Into(autoAnimate:myDFLBs,tmp[1]),Remove from(autoAnimate:myDFTPBs,i) ));
// which columns are used?
autoAnimate:DFCols = Transform Each( {TPB}, autoAnimate:myDFTPBs, Trim( Word( 1, TPB << Get Title, "(" ) ) );
// what are the entries? (for the filename)
autoAnimate:myDFLBItems = autoAnimate:myDFLBs << get items;
// how many entries?
autoAnimate:myDFLBNItems = Transform Each( {items}, autoAnimate:myDFLBItems, N Items( items ) );
// variales for the for loops
chars = {"aa", "bb", "cc", "dd", "ee", "ff", "gg", "hh", "ii"};
// append a Display Box:
Try(autoAnimate:animatePane << delete);
autoAnimate:DFTopLB << append( autoAnimate:animatePane = V List Box (Spacer Box( size( 0, 20 ) ),Panel Box( "cycle selected + save", V List Box( colSelection = List Box( autoAnimate:DFCols ), H List Box( Button Box("update",autoAnimate:update()),Spacer Box (size(40,0)),Button Box( "start", autoAnimate:animateNsave() ) )) ) ));
);
autoAnimate:animateNsave = Function( {},
// which DFs are selected?
selectedCols = colselection << Get Selected Indices;
// compose the expression
expression = "";
xx=1;
// for loop for every active DF:
For( i = 1, i <= N Items( autoAnimate:myDFTPBs ), i++,
expression = expression || If( Contains( selectedCols, i ),
"For(" || chars[i] || "=1," || chars[i] || "<=" || Char( autoAnimate:myDFLBNItems[i] ) || "," || chars[i] || "++,__LB" || Char( i ) ||
"__ << clear selection << set selected(" || chars[i] || ");",
"if(1,"
)
);
// save current Graph builder Plot -- how about other reports?
expression = expression || "wait();(current report()<< XPath(\!"//OutlineBox[@helpKey='Graph Builder']\!"))<<SAVE picture=""></SAVE>回覆:將圖表儲存為 PNG 或 JPEG@hogi ,這個腳本太棒了!我與許多非 JMP 用戶分享我的分析結果,並且將此選單新增至具有本地資料過濾器的任何圖表中非常有幫助。
*對於初學者來說,注意到@hogi的腳本是獨立的並且可以添加到資料表中可能會有所幫助(透過使用資料表中左側面板頂部的紅色三角形並選擇「新腳本」)。然後,當您執行此腳本時,它會將小選單新增至已套用本機資料過濾器的目前活動報表中。
回覆:將圖表儲存為 PNG 或 JPEG它變得更容易了:)
我已將功能新增至圖形產生器工具列*)
*) 現在可透過市場購買:
https://marketplace.jmp.com/appdetails/Graph%20Builder%20Toolbar

回覆:將圖表儲存為 PNG 或 JPEG……但仍然是具有相同錯誤的版本。
如果你想加快速度,請將wait()的參數從 () 改為 ( 0) :
