gpt4 book ai didi

ios - 如何在Core Plot CPT ScatterPlot中绘制不同的线条颜色

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:07:35 35 4
gpt4 key购买 nike

enter image description here

现在,我可以使用 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 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;

最佳答案

为此,您必须使用多个散点图。每种不同的颜色使用一个。

关于ios - 如何在Core Plot CPT ScatterPlot中绘制不同的线条颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36171384/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com