Iphone 如何使用coreplot在散点图中获得3个图例框?
我添加了此代码以添加绘图。使用上述代码,我只能绘制一个图例框。但我的要求是获得三个图例框。我哪里做错了。请验证代码并让我知道我哪里做错了?除非您省略了一些设置代码,问题是在创建图例时,图形没有任何绘图。将绘图添加到图形后,可以使用Iphone 如何使用coreplot在散点图中获得3个图例框?,iphone,core-plot,Iphone,Core Plot,我添加了此代码以添加绘图。使用上述代码,我只能绘制一个图例框。但我的要求是获得三个图例框。我哪里做错了。请验证代码并让我知道我哪里做错了?除非您省略了一些设置代码,问题是在创建图例时,图形没有任何绘图。将绘图添加到图形后,可以使用+legendWithGraph:创建图例,也可以稍后使用-addPlot:或-insertPlot:atIndex:方法将其添加到图例中。这很好。将绘图添加到图形后,请确保将最初发布的图例建筑代码移动到某个点。 I am unable to put three leg
+legendWithGraph:
创建图例,也可以稍后使用-addPlot:
或-insertPlot:atIndex:
方法将其添加到图例中。这很好。将绘图添加到图形后,请确保将最初发布的图例建筑代码移动到某个点。
I am unable to put three legend boxes on the graph.I have tried the following code
CPTGraph *graph1 = self.hostView.hostedGraph;
CGFloat legendPadding = -(self.view.bounds.size.width / 8);
graph1.legendDisplacement = CGPointMake(legendPadding, 0.0);
CPTLegend *theLegend1 = [CPTLegend legendWithGraph:graph1];
theLegend1.numberOfColumns = 1;
theLegend1.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
theLegend1.borderLineStyle = [CPTLineStyle lineStyle];
theLegend1.cornerRadius = 5.0;
graph1.legend = theLegend1;
graph1.legendAnchor = CPTRectAnchorTop;
CGFloat legendPadding1 = -(self.view.bounds.size.width / 4);
graph1.legendDisplacement = CGPointMake(legendPadding1, 0.0);
where am i going wrong ?
Here is the code for adding plots:
CPTGraph *graph = self.hostView.hostedGraph;
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;
plotSpace.delegate = self;
// 2 - Create the three plots
aaplPlot = [[[CPTScatterPlot alloc] init]autorelease];
aaplPlot.dataSource = self;
aaplPlot.identifier = @"MaxWeight";
CPTColor *aaplColor = [CPTColor magentaColor];
[graph addPlot:aaplPlot toPlotSpace:plotSpace];
googPlot = [[[CPTScatterPlot alloc] init]autorelease];
googPlot.dataSource = self;
googPlot.identifier = @"MinWeight";
CPTColor *googColor = [CPTColor greenColor];
[graph addPlot:googPlot toPlotSpace:plotSpace];
msftPlot = [[[CPTScatterPlot alloc] init]autorelease];
msftPlot.dataSource = self;
msftPlot.identifier = @"NormalWeight";
CPTColor *msftColor = [CPTColor blueColor];
[graph addPlot:msftPlot toPlotSpace:plotSpace];
[plotSpace scaleToFitPlots:[NSArray arrayWithObjects:aaplPlot,msftPlot,googPlot,nil]];