尊敬的JMP用户,
我想使用JSL从配置文件中更新列名称,并进行绘图,在其标题和轴中将包含更新的列名称。 我正在寻找有关如何执行此操作的想法。
到目前为止,我将附加我的代码和表格。 谢谢您的帮助。
我已经附上了我希望最终图形看起来像什么(desired_Bivariate)
-西蒙
Names Default To Here( 1 );
dt = Open( "table_1.jmp" );
dt1 = Open( "config_table.jmp" );
dt1 << New Column( "New Column", character, formula( Column_name || "_" || additional_name ) );
graph = dt << Bivariate( Y( :height ), X( :id ) );
尝试这个:
Names Default To Here( 1 );
dt = Open( "table_1.jmp" );
dt1 = Open( "config_table.jmp" );
for(i = 1, i <= N Rows(dt1), i++,
x = Column(dt1, "Column_name")[i];
y = Column(dt1, "additional_name")[i];
Column(dt, i) << Set Name( x || "_" || y);
);
这里有两种解决问题的方法,它们不会更改列的实际名称,而是可以满足您的要求。第一个创建的Transform列具有为双变量运行指定的新名称。这些列仅适用于双变量执行。

第二个示例对数据表中的不同列使用“单位列”属性。JMP中的平台使用Units列属性,并通过将Units值放在列名之后的()中来显示它作为实际列名的补充。

// This version of the script used Transform variables
// to temporarially change the name of the column just
// for the running of the Bivariate
Names Default To Here( 1 );
dt = Data Table( "table_1" );
dt1 = Data Table( "config_table" );
// Loop across the columns to run the Bivariate
For( i = 2, i <= N Cols( dt ), i++,
// Check to see if a column name change is specified
// in the config table
foundRow = dt1 << get rows where(
:Column_name == Column( dt, i ) << get name & dt1
:additional_name != ""
);
// If a column name change is found make the change
If( N Rows( foundRow ) > 0,
Eval(
Substitute(
Expr(
Bivariate(
Y(
Transform Column(
__trans__,
Formula( __col__ )
)
),
X( :id )
)
),
Expr( __trans__ ),
dt1:Column_name[foundRow[1]] || "_" || dt1
:additional_name[foundRow[1]],
Expr( __col__ ),
Parse( ":" || dt1:Column_name[foundRow[1]] )
)
),
// otherwise just run the bivariate
dt << Bivariate( Y( Column( i ) ), X( :id ) )
);
);
// This version of the script takes advantage of the Units
// column property. It will automatically add (unit value) to
// the display output, without actually changing the columns
// name
Names Default To Here( 1 );
dt = Data Table( "table_1" );
dt1 = Data Table( "config_table" );
// Add the Units Column Property to the columns in the
// original data table
For( i = 1, i <= N Cols( dt ), i++,
foundRow = dt1 << get rows where(
:Column_name == Column( dt, i ) << get name & dt1
:additional_name != ""
);
If( N Rows( foundRow ) > 0,
column( dt, i ) << set property("units", eval(dt1:additional_name[foundRow[1]]));
);
);
// Now run the normal bivariates
For( i = 2, i <= N Cols( dt ), i++,
dt << Bivariate( Y( Column( i ) ), X( :id ) )
);