Core Plot: increasing space between ticks on x axis?

I have this code for creating ticks and labels on the x axis:

    CPTAxis *x = axisSet.xAxis;
    x.title = @"Hour of Day";
    x.titleTextStyle = axisTitleStyle;
    x.titleOffset = 15.0f;
    x.axisLineStyle = axisLineStyle;
    x.labelingPolicy = CPTAxisLabelingPolicyNone;
    x.labelTextStyle = axisTextStyle;
    x.majorTickLineStyle = axisLineStyle;
    x.majorTickLength = 4.0f;
    x.tickDirection = CPTSignNegative;
    CGFloat dateCount = [timestamps count];
    NSMutableSet *xLabels = [NSMutableSet setWithCapacity:dateCount];
    NSMutableSet *xLocations = [NSMutableSet setWithCapacity:dateCount];
    NSInteger i = 0;
    for (NSString *date in timestampStrings) {
        CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:date textStyle:x.labelTextStyle];
        CGFloat location = i++;
        label.tickLocation = CPTDecimalFromCGFloat(location);
        label.offset = x.majorTickLength;
        if (label) {
            [xLabels addObject:label];
            [xLocations addObject:[NSNumber numberWithFloat:location]];
        }
    }
    x.axisLabels = xLabels;
    x.majorTickLocations = xLocations;

I was wondering if I can expand the distance between each tick, because now it looks like a flattened mess that does not match the dots. Is there a way to make more space between each tick, say 10 pixels? Thank!

+3
source share
2 answers

I checked it and it all lay in CGFloat location = i++;. I changed this to what I wanted (5, as in pixels):

CGFloat location = i+=5;

and it worked.

0
source

, CPTXYGraph CPTXYPlotSpace. plotSpace.globalXRange plotSpace.xRange, X.
globalXRange , xRange . , xRange globalXRange.

0

All Articles