4.25 FAQ-384 Origin 如何为数据提供适当的刻度线标签?

Last Update: 7/9/2018

在 LabTalk 中,limit 命令可用于设置正确的坐标轴刻度和计算合理的刻度标签。例如:

newbook;
range rax = 1!col(a);
rax = data(17.3,23.6,.25);
range ray = 1!col(b);
ray = normal(rax.GetSize());

// calculate statistics descriptive values for X and Y datasets
stats rax;  
size = stats.n;
Xbegin = stats.min;
Xend = stats.max;
stats ray;  
Ybegin = stats.min;
Yend = stats.max;
 
// calculate the appropriate increment value and adjust begin and end values
ticks = 5;
ty Beginning with From : $(Xbegin), To : $(Xend), Steps : $(ticks);
limit -r Xbegin Xend ticks increment;
ty Limit command creates From : $(Xbegin), To : $(Xend), Increment : $(increment);

plotxy (1,2);

计算得出的 begin, end 和 increment 的值可分别用于设置坐标轴的 FromToIncrement

所有的 Origin 标准模板都包含了 8% 的边距。所以上述的计算例子中,该边距也被被默认添加到 X 和 Y 数据的范围内。该边距属性可通过以下的方法进行修改:

layer.x.rescalemargin
或者
layer.y.rescalemargin



Keywords:range, automatic scaling, axis, axes, 自动缩放,坐标轴