Core Plot辅助轴标签显示问题

时间:2013-05-28 13:59:45

标签: graph core-plot axis-labels

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

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更改了标题属性。

这是我的plotspace设置:

  

块引用

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)];

1 个答案:

答案 0 :(得分:1)

您已将yy2设置为同一轴对象。而是为y2创建一个新的轴对象:

CPTXYAxis *y2 = [[CPTXYAxis alloc] init];