【问题标题】:Adjust the distance between tick marks in either x or y axis on a scatter plot graph in Core Plot调整 Core Plot 中散点图上 x 或 y 轴上刻度线之间的距离
【发布时间】:2015-06-22 15:52:12
【问题描述】:

我有一个使用 CorePlot 的散点图。对于 Y 轴,我在提供的刻度线之间有自定义间隔。

  yAxis.labelingPolicy = CPTAxisLabelingPolicyLocationsProvided;

  NSArray *labels = [NSArray arrayWithObjects:@"100",@"280",@"360",@"860",@"910",nil];

NSMutableSet *amountLabels = [NSMutableSet set];
NSMutableSet *majorTickLocations = [NSMutableSet set];


[creditScores
 enumerateObjectsUsingBlock:
 ^(NSString *amount, NSUInteger index, BOOL *stop)
 {
     CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:score textStyle:[self defaultTextStyle]];

     NSNumber *location = [NSNumber numberWithFloat:[amount floatValue]];
     [majorTickLocations addObject:location];
     label.tickLocation = CPTDecimalFromCGFloat([location floatValue]);
     [amountLabels addObject:label];
 }];


yAxis.majorTickLocations = majorTickLocations;
yAxis.axisLabels = amountLabels;

我想调整每个刻度线之间的物理距离(以点或像素为单位)。我想要的设计不会按比例正确。有没有办法设置或定义每个刻度线之间的距离?

【问题讨论】:

    标签: ios core-plot


    【解决方案1】:

    刻度间距由绘图范围(在本例中为 yRange)、绘图区域图层的大小和刻度线的位置共同决定。刻度线将像素对齐,以便它们清晰地绘制,但调整位置的唯一方法是更改​​上述一个或多个因素。

    增加绘图范围的长度会使更多的数据值可见,将这些值压缩在一起。增加绘图区域的大小(例如,通过更改图形和/或填充的大小)将使刻度线分开。

    【讨论】:

      猜你喜欢
      • 2018-02-22
      • 1970-01-01
      • 1970-01-01
      • 2018-10-01
      • 1970-01-01
      • 2022-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多