简体   繁体   English

iOS Coreplot多个Y轴

[英]ios coreplot multiple y-axis

i have been searching for this question for an answer for 3 days but could not figure it out. 我一直在寻找这个问题的答案3天,但无法弄清楚。

i need to add 3 scatterplots to a graph and here's my code : 我需要将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];

for initializations and creating 3 differend plotspaces like : 用于初始化并创建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;

and finally creating my plot like : 最后创建我的情节,如:

CPTScatterPlot *plot = [[CPTScatterPlot alloc] init];
plot.dataSource = self;
plot.identifier = @"mainplot";
plot.dataLineStyle = lineStyle;
plot.plotSymbol = nil;
plot.plotSpace = plotSpace;

and when i run this , 3 lines are added but i got only 1 y-axis. 当我运行它时,添加了3条线,但我只有1个y轴。 could not figure out the problem. 无法解决问题。

any help will be appreciated. 任何帮助将不胜感激。

  1. Did you add the new axes to the graph? 您是否已将新轴添加到图形?

     graph.axisSet.axes = [NSArray arrayWithObjects:x, lefty, righty, nil]; 
  2. If all of the axes and plots will have the same plot ranges, you can use the same plot space for all of them. 如果所有轴和图都具有相同的图范围,则可以对所有轴和图使用相同的图空间。 A new graph starts with one you can use ( defaultPlotSpace ). 一个新的图以您可以使用的图开始( defaultPlotSpace )。 Use the -addPlotSpace: method to add additional plot spaces to the graph. 使用-addPlotSpace:方法可将其他绘图空间添加到图形中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM