在 Core Plot 中绘制切线图
Drawing tangent plot in Core Plot
我正在制作绘图仪应用程序。创建绘图区域后,我设法使用 -addCurve:index
将图表添加到该区域,如下所示。
-(void)addCurve:(int)index {
// identifier
NSString *identifier = [NSString stringWithFormat:@"plot%d", index];
CPTScatterPlot *boundLinePlot = [[CPTScatterPlot alloc] init];
CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
lineStyle.miterLimit = 1.0f;
lineStyle.lineWidth = 3.0f;
lineStyle.lineColor = [CPTColor colorWithCGColor:[colorArray[index-1] CGColor]];
boundLinePlot.dataLineStyle = lineStyle;
boundLinePlot.identifier = identifier;
boundLinePlot.dataSource = self;
[graph addPlot:boundLinePlot toPlotSpace:plotSpace];
// interpolatiom
boundLinePlot.interpolation = CPTScatterPlotInterpolationCurved;
}
但是,当我绘制正切函数时,最高点和最低点连接起来,每两条曲线之间出现垂直线。任何人都知道我怎样才能摆脱他们?谢谢。
您需要在数据(return nil
或 [NSNull null]
来自数据源)中留出间隙,以在不连续处断开绘图线。
我正在制作绘图仪应用程序。创建绘图区域后,我设法使用 -addCurve:index
将图表添加到该区域,如下所示。
-(void)addCurve:(int)index {
// identifier
NSString *identifier = [NSString stringWithFormat:@"plot%d", index];
CPTScatterPlot *boundLinePlot = [[CPTScatterPlot alloc] init];
CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
lineStyle.miterLimit = 1.0f;
lineStyle.lineWidth = 3.0f;
lineStyle.lineColor = [CPTColor colorWithCGColor:[colorArray[index-1] CGColor]];
boundLinePlot.dataLineStyle = lineStyle;
boundLinePlot.identifier = identifier;
boundLinePlot.dataSource = self;
[graph addPlot:boundLinePlot toPlotSpace:plotSpace];
// interpolatiom
boundLinePlot.interpolation = CPTScatterPlotInterpolationCurved;
}
但是,当我绘制正切函数时,最高点和最低点连接起来,每两条曲线之间出现垂直线。任何人都知道我怎样才能摆脱他们?谢谢。
您需要在数据(return nil
或 [NSNull null]
来自数据源)中留出间隙,以在不连续处断开绘图线。