2016-03-23 12 views
2

enter image description hereWie verschiedene Linienfarbe in Core-Plot CPTScatterPlot

Vorerst ziehen, kann ich CPTScatterPlot ein Trend Chart wie diese ziehen.
30 Punkte und rote Linie miteinander verbinden.

Aber ich möchte verschiedene Linienfarbe zwischen den einzelnen Punkten verwenden.

Dies ist mein Code, den ich

versuchen
CPTXYGraph *graph = [[CPTXYGraph alloc] initWithFrame:self.frame]; 
    self.hostedGraph = graph; 

    CPTScatterPlot *scatterPlot = [[CPTScatterPlot alloc] initWithFrame:graph.bounds]; 
    scatterPlot.dataSource = self; 
    [graph addPlot:scatterPlot]; 

    CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle]; 
    lineStyle.lineWidth = 1.0f; 
    lineStyle.lineColor = [CPTColor redColor]; 
    scatterPlot.dataLineStyle = lineStyle; 

    CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) scatterPlot.plotSpace; 
    plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:@0 length:@(self.dataModel.data.count -1)]; 
    plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:d length:@([c integerValue] - [d integerValue])]; 

    CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet; 
    CPTXYAxis *x = axisSet.xAxis; 
    CPTXYAxis *y = axisSet.yAxis; 
    x.orthogonalPosition = z; 
    x.labelingPolicy = CPTAxisLabelingPolicyNone; 
    y.orthogonalPosition = @0; 
    y.labelingPolicy = CPTAxisLabelingPolicyNone; 

    CPTMutableLineStyle *symbolLineStyle = [CPTMutableLineStyle lineStyle]; 
    symbolLineStyle.lineColor = [CPTColor blackColor]; 
    symbolLineStyle.lineWidth = 1.0; 

    CPTPlotSymbol *plotSymbol = [CPTPlotSymbol ellipsePlotSymbol]; 
    plotSymbol.fill = [CPTFill fillWithColor:[CPTColor redColor]]; 
    plotSymbol.lineStyle = symbolLineStyle; 
    plotSymbol.size = CGSizeMake(5.0, 5.0); 
    scatterPlot.plotSymbol = plotSymbol; 

Antwort

1

Sie haben dafür mehrere Streudiagramme zu verwenden. Verwenden Sie eine für jede andere Farbe.

Verwandte Themen