Adjust the distance between tick marks in either x or y axis on a scatter plot graph in Core Plot

320 views Asked by At

I have a scatter plot using CorePlot. For the Y Axis, I have custom intervals between tick marks that are provided.

  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;

I want to adjust the physical distance (in points or pixels) between each tick mark. The design I want will not be proportionally correct. Is there a way to set or define the distance between each tick mark?

1

There are 1 answers

0
Eric Skroch On

The tick spacing is determined by the combination of the plot range (the yRange in this case), the size of the plot area layer, and the locations of the tick marks. The tick lines will be pixel aligned so they draw sharply, but otherwise the only way to adjust the position is to change one or more of the factors above.

Increasing the length of the plot range makes more data values visible, squeezing the values together. Increasing the size of the plot area (e.g., by changing the size of the graph and/or padding) will spread the tick marks apart.