将图表保存为 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 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) :
