iphone上ScatterPlotView中的CorePlot多数据/图形

iphone上ScatterPlotView中的CorePlot多数据/图形,iphone,Iphone,如何在coreplot中绘制多条直线 我可以画一个这样的数据 //创建绿色绘图区域 CPTScatterPlot *dataSourceLinePlot = [[[CPTScatterPlot alloc] init] autorelease]; dataSourceLinePlot.identifier = @"Green Plot"; CPTMutableLineStyle *lineStyle = [[dataSourceLinePlot.dataLineStyle mutableCop

如何在coreplot中绘制多条直线 我可以画一个这样的数据

//创建绿色绘图区域

CPTScatterPlot *dataSourceLinePlot = [[[CPTScatterPlot alloc] init] autorelease];
dataSourceLinePlot.identifier = @"Green Plot";

CPTMutableLineStyle *lineStyle = [[dataSourceLinePlot.dataLineStyle mutableCopy] autorelease];
    lineStyle.lineWidth = 2.f;
lineStyle.lineColor = [CPTColor greenColor];
    lineStyle.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:8.0f], nil];
dataSourceLinePlot.dataLineStyle = lineStyle;

dataSourceLinePlot.dataSource = self;

    // Put an area gradient under the plot above
CPTColor *areaColor = [CPTColor colorWithComponentRed:0.0 green:1.0 blue:0.0 alpha:1];
CPTGradient *areaGradient = [CPTGradient gradientWithBeginningColor:areaColor endingColor:[CPTColor clearColor]];
//areaGradient.angle = -90.0f;
CPTFill *areaGradientFill = [CPTFill fillWithGradient:areaGradient];
dataSourceLinePlot.areaFill = areaGradientFill;
// dataSourceLinePlot.areaBaseValue = CPTDecimalFromString(@"0.05");// green line  shade below point

    // Animate in the new plot, as an example
    dataSourceLinePlot.opacity = 0.2f;
    dataSourceLinePlot.cachePrecision = CPTPlotCachePrecisionDecimal;
[graph1 addPlot:dataSourceLinePlot];
但是如何添加2个图形数据,因为我想比较周数据

我知道我必须调整这一点,但这段代码接受Either的值,但不是两者都接受'

-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index 
{
    NSDecimalNumber *num = nil;
     {
        if ( index % 8 ) {
             num = [[dataForPlot objectAtIndex:index] valueForKey:(fieldEnum == CPTScatterPlotFieldX ? @"x" : @"y")];
            // Green plot gets shifted above the blue
            if ( [(NSString *)plot.identifier isEqualToString:@"Green Plot"] ) {
                if ( fieldEnum == CPTScatterPlotFieldY ) {

                    num = (NSDecimalNumber *)[NSDecimalNumber numberWithDouble:[num doubleValue] + 1.0];
                }
            }

            else if ( [(NSString *)plot.identifier isEqualToString:@"Green Plot1"] ) {
                num = [[dataForPlot1 objectAtIndex:index] valueForKey:(fieldEnum == CPTScatterPlotFieldX ? @"x" : @"y")];
                if ( fieldEnum == CPTScatterPlotFieldY ) {
                    num = (NSDecimalNumber *)[NSDecimalNumber numberWithDouble:[num doubleValue] + 1.0];
                }
            }
        }
        else {
            num = [NSDecimalNumber notANumber];
        }
    }

    return num;
}

我想同时显示绿色绘图和绿色绘图1数据

现在可以工作了,但是如何更改颜色

CPTSatterPlot*数据源线性图=[[CPTSatterPlot alloc]init]autorelease]; dataSourceLinePlot.identifier=@“绿色绘图”

//面积梯度。角度=-90.0f; CPTFill*areaGradientFill=[CPTFill fillWithGradient:areaGradient]; dataSourceLinePlot.areaFill=areaGradientFill; //dataSourceLinePlot.areaBaseValue=CPTDecimalFromString(@“0.05”);//点下方的绿线阴影

// Animate in the new plot, as an example
dataSourceLinePlot.opacity = 0.2f;
dataSourceLinePlot.cachePrecision = CPTPlotCachePrecisionDecimal;
[graph1 addPlot:dataSourceLinePlot];







CPTScatterPlot *dataSourceLinePlot1 = [[[CPTScatterPlot alloc] init] autorelease];
dataSourceLinePlot1.identifier = @"Green Plot1";
//CPTMutableLineStyle*lineStyle1=[[dataSourceLinePlot.dataLineStyle mutableCopy]自动释放]

CPTMutableLineStyle *lineStyle1= [CPTMutableLineStyle lineStyle];
lineStyle1.lineWidth = 12.f;
lineStyle1.lineColor = [CPTColor greenColor];
lineStyle1.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:18.0f], nil];
dataSourceLinePlot1.dataLineStyle = lineStyle;

dataSourceLinePlot1.dataSource = self;

// Put an area gradient under the plot above
CPTColor *areaColor1 = [CPTColor colorWithComponentRed:0.0 green:1.0 blue:0.0 alpha:1];
CPTGradient *areaGradient1 = [CPTGradient gradientWithBeginningColor:areaColor1 endingColor:[CPTColor clearColor]];
//areaGradient.angle = -90.0f;
CPTFill *areaGradientFill1 = [CPTFill fillWithGradient:areaGradient1];
dataSourceLinePlot1.areaFill = areaGradientFill1;
// dataSourceLinePlot.areaBaseValue = CPTDecimalFromString(@"0.05");// green line  shade below point

// Animate in the new plot, as an example
dataSourceLinePlot1.opacity = 0.2f;
dataSourceLinePlot1.cachePrecision = CPTPlotCachePrecisionDecimal;
[graph1 addPlot:dataSourceLinePlot1 ];//toPlotSpace:plotSpace
CPTMutableLineStyle *lineStyle1= [CPTMutableLineStyle lineStyle];
lineStyle1.lineWidth = 12.f;
lineStyle1.lineColor = [CPTColor greenColor];
lineStyle1.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:18.0f], nil];
dataSourceLinePlot1.dataLineStyle = lineStyle;

dataSourceLinePlot1.dataSource = self;

// Put an area gradient under the plot above
CPTColor *areaColor1 = [CPTColor colorWithComponentRed:0.0 green:1.0 blue:0.0 alpha:1];
CPTGradient *areaGradient1 = [CPTGradient gradientWithBeginningColor:areaColor1 endingColor:[CPTColor clearColor]];
//areaGradient.angle = -90.0f;
CPTFill *areaGradientFill1 = [CPTFill fillWithGradient:areaGradient1];
dataSourceLinePlot1.areaFill = areaGradientFill1;
// dataSourceLinePlot.areaBaseValue = CPTDecimalFromString(@"0.05");// green line  shade below point

// Animate in the new plot, as an example
dataSourceLinePlot1.opacity = 0.2f;
dataSourceLinePlot1.cachePrecision = CPTPlotCachePrecisionDecimal;
[graph1 addPlot:dataSourceLinePlot1 ];//toPlotSpace:plotSpace