在JSL中使用Graph Builder后如何更改X轴的比例(以及制图方法问题)你好
我正在编写一个脚本,该脚本将与具有多种列的文件一起使用,因此我不得不修改在此找到的示例,该示例根据列数将Graph Builder调用串联起来。尽管笨拙,它似乎确实起作用了,但是我的问题是我然后想将X轴更改为对数刻度,更改限制等。我尝试了“脚本索引”和示例中的几种方法,但似乎都没有用。
非常感谢在轴设置上朝着正确方向的指针,但是如果有人对如何更好地完成初始绘图部分有想法,那也将非常棒,谢谢!
dt = Current Data Table();
ColNameList = dt << Get Column Names (continuous, string);
//Start with initial graph builder
GraphExpr = "
TestGraph = Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables(";
//Add X Entry
GraphExpr = GraphExpr || "
X( :Name( \!"" || ColNameList[1] || "\!") ),";
//Add the first Y entry
GraphExpr = GraphExpr || "
Y( :Name( \!"" || ColNameList[2] || "\!") ),";
//Add the second Y entry
For( i = 3, i <= N items (ColNameList), i++,
GraphExpr = GraphExpr || "
Y( :Name( \!"" || ColNameList[i] || "\!"), Position (1) ),";
);
//Close out Variables section
GraphExpr = GraphExpr || "
),
Elements(
Line( X, Y( 1 )";
//Build out the lines for all columns
For( i = 2, i <= N items (ColNameList), i++,
GraphExpr = GraphExpr || ", Y( " || char(i) || " )"
);
GraphExpr = GraphExpr || ", Legend( 1 )
)
)
)";
eval(parse(GraphExpr));
TestGraph << Show Legend (0);
图形脚本编写回复:在JSL中使用Graph Builder后如何更改X轴的比例(以及制图方法问题)你好
实际上,这是构建Graph Builder表达式的相当复杂的方法。 您可能想研究使用“占位符”(gbe = Expr(Graph Builder(...))定义整个GB表达式的方法;使用替代函数用列,变量,标签等替换占位符。 ,然后使用Eval()函数生成图形(很抱歉,我现在没有时间提供更多详细信息)
对于您的特定问题,如果将Graph Builder表达式分配给变量(例如,gb = Graph Builder(...);),则可以使用以下方法以所需的任何方式更新轴:
gb = dt << Graph Builder(
Show Control Panel( 0 ),
Variables(
X( :age, Size( 23 ) ),
Y( :height, Size( 37 ) ),
Y( :weight, Position( 1 ), Size( 37 ), Side( "Right" ) )
),
Elements( Points( X, Y( 1 ), Legend( 1 ), Jitter( 1 ) ), Points( X, Y( 2 ), Legend( 3 ), Jitter( 1 ) ) )
);
framebox = Report( gb )[framebox( 1 )];
framebox << Y Axis(
Scale ("Log"),
Add Ref Line( 61.25, "Solid", "Medium Dark Green" ),
Show Major Grid( 1 ),
Show Minor Grid( 1 ),
Format( "Fixed Dec", 5, 2 ),
Rotated Labels( "Perpendicular" )
);我希望这有帮助。
最好,
TS
回复:在JSL中使用Graph Builder后如何更改X轴的比例(以及制图方法问题)AxisBox的脚本编制索引条目中提供了所有更改轴的消息。
您要使用的是
report(TestGraph)[AxisBox(2)] << scale(log);