[脚本 JLS] : 用于将多个图形绘制在一起的循环你好,
我是 JMP 的新手。是一款功能强大的软件!
这就是为什么我想编写一个脚本,它可以在一个 X 的函数中从不同的列(实际上是每 n 列)绘制多个 Y。
由于图形生成器界面,我编写了它,但我想在循环中编写它。
我做了类似的事情来绘制分布(但不幸的是它的比例不一样......)
//Distributions Std Dev
New Window( "Side by Side",
H List Box(
Distribution(
Continuous Distribution( Column( :median_range_mm ))
);
for ( p = 2, p <= 64, p++,
nom = "median_range_mm " || char(p);
col = Column(nom);
Distribution(
Continuous Distribution( Column( col ), Std Error Bars( 1 ) );
/*SendToReport(
Dispatch(
{"Distributions", Column( col )},
"1",
ScaleBox,
{Min( 1450 ), Max( 1820 ), Inc( 20 ), Minor Ticks( 0 ),
Label Row Nesting( 1 )}
)
)*/
)
)
)
这是我尝试解决的主要问题,结果只是图形生成器的一个打开窗口。
我想在 Y 轴上绘制列 [ref, ref 1 , ref 2 until ref 64] 并在 X 轴上绘制 currentTimeMillis
New Window( "Ref",
H List Box(
Graph Builder(
For (r = 2 , r <= 64, r++,
name = "ref " || char(r);
col = Column(name);
Variables( X( :currentTimeMillis ), Y (Column (col), Position( 1 ) ) ),
Elements(
Points( X, Y(r) , Legend( 29 ) ),
Smoother( X , Y(r), Legend( 30 ) )
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( strTitle )}
)
)
)
)
)
);谢谢你的帮助。
干杯
回复:[Script JLS]:循环绘制多个图表我有点困惑......但我提供此代码作为解决方案的可能示例。 从您提供的最后一段代码中可以看出,您正在将数据表中的列名更改为“Ref”。 由于 JMP 不允许您拥有 2 个同名列,因此您尝试重命名“Ref”的第二列实际上被命名为“Ref 2”。 这一直持续到“Ref 64”栏。 我还建议您重新检查您的代码以获取“currentTimeMillis”列的命名。 在您的代码中,您实际上将该列重命名(使用相同的名称)64 次。
下面是我的新代码......它使用了一个示例数据表......名为 Ref - Ref 64 的列都是连续的,但由于 JMP 真的不在乎,代码将也适用于您的数据表,其中的列分布在您的 700 多列中
Names Default To Here( 1 );
// Build some sample data
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
Column( dt, 6 ) << set name( "ref" );
For( i = 7, i <= 69, i++,
Column( dt, i ) << set name( "ref " || Char( i - 5 ) )
);
Column( dt, 5 ) << set name( "currentTimeMillis" );
// Build the JSL code for the Graph Builder
theExpr = "dt << Graph Builder(
Variables(
X( :currentTimeMillis ),
Y( :ref )";
For( i = 2, i <= 64, i++,
theExpr = theExpr || ",Y( :ref " || Char( i ) || ", Position( 1 ) )"
);
theExpr = theExpr || "),
Elements(
Points(
X";
For( i = 2, i <= 64, i++,
theExpr = theExpr || ",Y( " || Char( i ) || ")"
);
theExpr = theExpr || "
,Legend( 5 )
),
Smoother(
X";
For( i = 2, i <= 64, i++,
theExpr = theExpr || ",Y( " || Char( i ) || ")"
);
theExpr = theExpr || " ,
Legend( 6 )
)
)
)";
// Execute the generated code
Eval( Parse( theExpr ) );
回复:[Script JLS]:循环绘制多个图表谢谢你的回复吉姆!
但我可能歪曲了我的问题。
确实,我想拥有我所有的情节都在同一张图上.
此外,我的 Y 列已经每 11 列设置一次,并且 currentTimeMillis 在开头只出现一次:
//Set columns
For( i = 1, i <=709 , i++,
For ( j = 0, j <= 63, j++,
If ( i == 2, Column(i) << set name( "currentTimeMillis" ),i == 15 + 11*j, Column(i) << set name( "ref" ),
)
)
)最后,“__col__”尚未定义(“col”已定义,但在另一个分发函数中),所以我不明白你为什么在这里使用它。
再次感谢。
回复:[Script JLS]:循环绘制多个图表这是我将如何做的一个例子
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
For( i = 6, i <= 69, i++,
Column( dt, i ) << set name( "ref " || Char( i - 5 ) )
);
Column( dt, 5 ) << set name( "currentTimeMillis" );
New Window( "Ref",
hlb = H List Box(
)
);
For( r = 2, r <= 64, r++,
name = "ref " || Char( r );
Eval(
Substitute(
Expr(
outputhlb = H List Box(
Graph Builder(
Variables(
X( :currentTimeMillis ),
Y( Column( __col__ ), Position( 1 ) )
),
Elements(
Points( X, Y( r ), Legend( 29 ) ),
Smoother( X, Y( r ), Legend( 30 ) )
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( strTitle )}
)
)
)
)
),
Expr( __col__ ), Parse( ":" || name )
)
);
hlb << append( outputhlb );
);
回复:[Script JLS]:循环绘制多个图表是否可以保存单个图形(如简单访问列表)以供以后使用,而不是将它们全部绘制在一个 H 列表框中?谢谢。