目前,我可以使用 CPTScatterPlot 绘制这样的趋势图。
30个点和红线相互连接。
但我想在每个点之间使用不同的线条颜色。
这是我正在尝试的代码
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 plotRangeWithLocation0 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;
Best Answer-推荐答案 strong>
您必须为此使用多个散点图。为每种不同的颜色使用一个。
关于ios - 如何在 Core Plot CPT ScatterPlot 中绘制不同的线条颜色,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/36171384/
|