在脚本内调用内置 JMP 菜单函数大家好,
这里是缺乏经验的 JSL 脚本编写者。 如果这是一个微不足道的问题,我深表歉意,但我想知道是否有一种方法可以从内部将特定旋转角度的 scatterplot 3D 命令插入到变量中(由用户通过手动执行 scatterplot 3D 生成的 3D 图形的旋转预先确定) JSL 脚本。 例如,
sp = Scatterplot 3D(
Y( :age, :height, :weight ),
Frame3D( Set Grab Handles( 0 ), Set Rotation( -54, 0, 38 ) )
);
,但想法是能够做到这一点,而无需手动将旋转值复制粘贴到代码中,因为我正在尝试自动化一个过程,该过程需要来自已生成的散点图的旋转值作为输入。 最终目标是拥有一个脚本,该脚本将预定的旋转值作为输入,并与 R 脚本(已编写)交互,以从 3D 散点图生成 2D 绘图。这将使我能够避免使用 Mac 剪贴板的不便。
如有任何帮助,我们将不胜感激,谢谢。
自动化和脚本编写质量和工艺工程回复:在脚本中调用内置 JMP 菜单函数我认为存在期望不匹配的情况。JMP 社区中讨论组的目的不是根据 JMP 用户的请求提供完整的解决方案。我提供的脚本需要被视为解决该问题的一种方法的说明。供用户扩展其最终解决方案的学习工具。
现在,为了解决最后一个条目的问题,您如何设想 JMP 用户运行您想要的脚本?他们将如何选择在散点图中使用哪些列?
如果计划是让用户只运行 3D 散点图,然后当他们将绘图绘制到他们想要的点时,然后运行脚本以剥离脚本并获取列和旋转,这里是一个片段JSL 找到散点图窗口,然后从我的上一个条目中获取代码,创建一个 csv 文件
Names Default To Here( 1 );
// Find the current report
curReport = Current Report();
// Check to see if the JMP current report is actually the Scatterplot 3D report
If( curReport[Outline Box( 1 )] << get title == "Scatterplot 3D",
theScript = Char( (xx[Outline Box( 1 )] << get scriptable object) << get script );
dt = Current Data Table();
,
// If not, find the window that is the 3D plot
i = 1;
While( Try( Window( i )[Outline Box( 1 )] << get title, "" ) != "Scatterplot 3D" & i < 100, i++ );
If( i < 100,
curReport = Window( i )[Outline Box( 1 )];
theScript = Char( (curReport[Outline Box( 1 )] << get scriptable object) << get script );
dt = Data Table( Trim( Word( 1, Window( i ) << get window title, "-" ) ) );
,
// If no Scatterplot 3D is jound, display an error
Dialog( "Error: No Scatterplot 3D was found" );
Throw();
);
);
// If the code makes it to here, strip off the script components needed
varsList = {};
Insert Into( varsList, Word( 2, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
Insert Into( varsList, Word( 4, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
Insert Into( varsList, Word( 6, Substr( theScript, Contains( theScript, "Y(" ) ), ":,)" ) );
rotationList = {};
Insert Into( rotationList, Word( 2, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
Insert Into( rotationList, Word( 3, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
Insert Into( rotationList, Word( 4, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
// Add the columns used and the rotations to a new data table
dtSub = dt << subset( columns( Eval( varsList ) ), selected rows( 0 ) );
dtSub << New Column( "_Vars_", character, set values( varsList ) );
dtSub << New Column( "_Rotation_", character, set values( rotationList ) );
dtSub << Save( "$TEMP/passvalues.csv" );
Close( dtSub, nosave );
回复:在脚本中调用内置 JMP 菜单函数感谢您提供的有用建议。 将尝试将其集成到我的解决方案中。 这是有道理的。 我对此 JSL 唯一关心的是,对于每个新数据集,我必须为我想要运行脚本的每个新数据集手动输入 3 个新列名称(:age 等...),在我的例子中就会违背使这个过程自动化的目的。回复:在脚本中调用内置 JMP 菜单函数这个讨论问题似乎与之前的讨论相关或相同的问题从 3D 散点图脚本中选择旋转和数据列
要回答这篇文章中的具体问题,您的脚本
sp = Scatterplot 3D(
Y( :age, :height, :weight ),
Frame3D( Set Grab Handles( 0 ), Set Rotation( -54, 0, 38 ) )
);
运行时,生成一个输出显示对象,可以通过创建指向该对象的变量在 JSL 中访问该对象
spr = report( sp );
//or
spr = sp << report;
“spr”不包含散点图,而是指向输出显示树中顶部对象的指针,该对象包含散点图以及与输出显示关联的各种对象。
以下是我为上述讨论问题编写的脚本。在其中,它允许用户运行 3D 散点图,当散点图关闭时,它会进入显示树并提取 JMP 脚本,如果运行该脚本,将重新生成 3D 散点图,就像它在运行时一样关门了。然后,该脚本继续提取 3 个轴的列和旋转值,并将其放入分别称为 varsList 和rotationList 的 2 个 JMP 列表中。然后,它将这些值作为新列添加回原始 JMP 数据表,然后将数据表保存为 csv 文件。
不知道 csv 文件中需要什么格式传递给 R,这只是对所需内容的猜测。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
sp = Scatterplot 3D(
Y( :age, :height, :weight ),
Frame3D( Set Grab Handles( 0 ), Set Rotation( -54, 0, 38 ) )
);
sp << on close(
theScript = Char( (Report( sp ) << get scriptable object) << get script );
varsList = {};
Insert Into( varsList, Word( 2, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
Insert Into( varsList, Word( 4, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
Insert Into( varsList, Word( 6, Substr( theScript, Contains( theScript, "Y(" ) ), ":,)" ) );
rotationList = {};
Insert Into( rotationList, Word( 2, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
Insert Into( rotationList, Word( 3, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
Insert Into( rotationList, Word( 4, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
dtSub = dt << subset( columns( Eval( varsList ) ), selected rows( 0 ) );
dtSub << New Column( "_Vars_", character, set values( varsList ) );
dtSub << New Column( "_Rotation_", character, set values( rotationList ) );
dtSub << Save( "$TEMP/passvalues.csv" );
close( dtSub, nosave );
);
// This line opens the csv back into JMP
//open("$TEMP/passvalues.csv");
作为 JMP 工作原理的注释,无法将散点图放入变量中,然后将其传递给 R 或将其保存为 .csv 文件。但是,可以在将图像保存到图像文件时提取散点图的图像,或者将图像作为 blob 传递。我不太清楚你在找什么。您可能想要研究 JMP 自动化,它允许您从 JMP 调用 R,并将所需信息直接从 JMP 传递到 R。
请返回社区并提供您所需要的更多具体信息,我们将尽力帮助您解决问题。
最后,我强烈建议您花时间阅读《JMP/JSL 脚本指南》,该指南可以在“帮助”下拉菜单下的 JMP 文档库中找到。
回复:在脚本中调用内置 JMP 菜单函数作为后续,有没有办法将当前打开的散点图插入到变量中?