我一直在寻找这个问题的答案 3 天,但无法弄清楚。
我需要在图表中添加 3 个散点图,这是我的代码:
CPTXYAxis *x = [[CPTXYAxis alloc] init];
CPTXYAxis *lefty = [[CPTXYAxis alloc] init];
CPTXYAxis *righty = [[CPTXYAxis alloc] init];
x.coordinate = CPTCoordinateX;
lefty.coordinate = CPTCoordinateY;
righty.coordinate = CPTCoordinateY;
CPTAxisSet *axisSetTmp = [[CPTAxisSet alloc] init];
用于初始化并创建 3 个不同的绘图空间,例如:
float xAxisMin = 0;
float xAxisMax = 350;
float yAxisMin = 0;
float yAxisMax = 50;
// We modify the graph's plot space to setup the axis' min / max values.
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)self.graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(xAxisMin) length:CPTDecimalFromFloat(xAxisMax - xAxisMin)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(yAxisMin) length:CPTDecimalFromFloat(yAxisMax - yAxisMin)];
x.plotSpace = plotSpace;
最后创建我的情节,如:
CPTScatterPlot *plot = [[CPTScatterPlot alloc] init];
plot.dataSource = self;
plot.identifier = @"mainplot";
plot.dataLineStyle = lineStyle;
plot.plotSymbol = nil;
plot.plotSpace = plotSpace;
当我运行它时,添加了 3 行但我只有 1 个 y 轴。无法弄清楚问题所在。
任何帮助将不胜感激。