1

我需要绘制一个散点图,其中 x 轴应与 y 轴在 (0,60) 处相交。我还需要 y 轴上的 20 间隔。

我现在面临的问题是:

  1. y轴从0开始
  2. y 轴标签示例之间的差距,从 60 到 80 太大了。

到目前为止我做了什么:

设置交点:

x.orthogonalCoordinateDecimal = CPTDecimalFromString(@"60");

设置主要刻度位置:

NSSet *majorTickLocations = [NSSet setWithObjects:[NSDecimalNumber zero],
     [NSDecimalNumber numberWithUnsignedInteger:60],
     [NSDecimalNumber numberWithUnsignedInteger:80],
     [NSDecimalNumber numberWithUnsignedInteger:100],
     [NSDecimalNumber numberWithUnsignedInteger:120],
     nil];

y.majorTickLocations = majorTickLocations;

任何指向该方向的指针都会有所帮助。

问候,伊山

4

1 回答 1

2

要使轴在 (0, 60) 处交叉,请设置orthogonalCoordinateDecimal每个轴的 :

x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(60.0);
y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(0.0);

轴标签策略决定了刻度线和标签的位置。如果您自己提供刻度和标签位置 ( CPTAxisLabelingPolicyNone),您可以将它们放在您想要的任何位置。有关每个可用标签策略的示例,请参阅Plot Gallery示例应用程序中的“轴标签策略”演示。

于 2013-09-13T16:29:19.683 回答