0
votes

I'm making a graph plotter app. After creating a plot area, I manage to add graphs into the area using -addCurve:index as below.

-(void)addCurve:(int)index {

    // identifier
    NSString *identifier = [NSString stringWithFormat:@"plot%d", index];

    CPTScatterPlot *boundLinePlot  = [[CPTScatterPlot alloc] init];
    CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
    lineStyle.miterLimit        = 1.0f;
    lineStyle.lineWidth         = 3.0f;
    lineStyle.lineColor         = [CPTColor colorWithCGColor:[colorArray[index-1] CGColor]];
    boundLinePlot.dataLineStyle = lineStyle;
    boundLinePlot.identifier    = identifier;
    boundLinePlot.dataSource    = self;
    [graph addPlot:boundLinePlot toPlotSpace:plotSpace];

    // interpolatiom
    boundLinePlot.interpolation = CPTScatterPlotInterpolationCurved;
}

However, when I plot a tangent function, highest points and lowest points get connected and vertical lines between every two curves occur. Anyone know how I can get rid of them? Thank you.

1

1 Answers

0
votes

You need to leave a gap in the data (return nil or [NSNull null] from the datasource) to break the plot line at the discontinuity.