0

我已经成功创建了两个系列(每个绘图空间一个),每个系列都使用自己的比例。我用这段代码创建了轴:

CPTXYAxisSet *axisSet = (CPTXYAxisSet *) self.hostView.hostedGraph.axisSet;
CPTXYAxis *x = axisSet.xAxis;
CPTXYAxis *y = axisSet.yAxis;
CPTXYAxis *y2 = axisSet.yAxis;
y.plotSpace = plotSpace;
y2.plotSpace = plotSpace2;
graph.axisSet.axes = [NSArray arrayWithObjects:x, y, y2, nil];

该代码可以正确设置 y 的属性,但是当代码到达设置 y2 的属性时,例如:

y2.title = @"Velocity (m/s)";

y 改变了它的 title 属性。

这是我的绘图空间设置:

块引用

graph = self.hostView.hostedGraph;
plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;
graph.plotAreaFrame.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
[graph addPlotSpace:plotSpace];

CPTScatterPlot *forcePlot = [[CPTScatterPlot alloc] init];
forcePlot.dataSource = self;
forcePlot.identifier = CPDForce;
[graph addPlot:forcePlot toPlotSpace:plotSpace];
[graph addPlotSpace:plotSpace2];
CPTScatterPlot *velPlot = [[CPTScatterPlot alloc] init];
velPlot.dataSource = self;
velPlot.identifier = CPDVelocity;
[graph addPlot:velPlot toPlotSpace:plotSpace2];

[plotSpace scaleToFitPlots:[NSArray arrayWithObjects:forcePlot, nil]];
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(SlopeTime)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(MaxForce+0.1*MaxForce)];

[plotSpace2 scaleToFitPlots:[NSArray arrayWithObjects:velPlot, nil]];
plotSpace2.xRange = plotSpace.xRange;
plotSpace2.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(MaxVelocity+0.1*MaxVelocity)];
4

1 回答 1

1

您已将y和设置y2为相同的轴对象。y2改为创建一个新的轴对象:

CPTXYAxis *y2 = [[CPTXYAxis alloc] init];
于 2013-05-29T01:18:04.517 回答