在iOS中的CorePlot图上画一条虚线

在iOS中的CorePlot图上画一条虚线,ios,core-plot,Ios,Core Plot,如何使用核心图在图形上绘制虚线,该线表示轴的最大和最小范围 在AndroidPlot中,ValueMarker用于在图形上绘制最大和最小水平线 请帮我做这个 谢谢这是我在这种情况下使用的: @property (nonatomic, retain) CPTScatterPlot *myLine; @property (nonatomic, retain) CPTGraph *graph; -(void) configureHorizontalLine { //

如何使用核心图在图形上绘制虚线,该线表示轴的最大和最小范围

在AndroidPlot中,ValueMarker用于在图形上绘制最大和最小水平线

请帮我做这个


谢谢

这是我在这种情况下使用的:

@property (nonatomic, retain) CPTScatterPlot *myLine;
@property (nonatomic, retain) CPTGraph *graph;

    -(void) configureHorizontalLine
    {
        // 1 - Create plot space
        CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) self.graph.defaultPlotSpace;

        // 2 - Create the plot
        self.myLine = [[CPTScatterPlot alloc] init];
        self.myLine.dataSource = self;
        self.myLine.identifier = @"myLine";

        CPTColor *myPlotColor = [CPTColor redColor];
        [self.graph addPlot:self.myLine toPlotSpace:plotSpace];

        // 3 - Create styles
        CPTMutableLineStyle *myPlotLineStyle = [self.myLine.dataLineStyle mutableCopy];

        myPlotLineStyle.dashPattern=[NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:3],nil];  //dashed line

        myPlotLineStyle.lineWidth = 1;
        myPlotLineStyle.lineColor = myPlotColor;
        self.myLine.dataLineStyle = myPlotLineStyle;
    }
同样,在
CPTPlotDataSource
方法中,您必须执行以下检查以识别线图:

if ([[plot identifier] isEqual:@"myLine"])

这就是我在这种情况下使用的方法:

@property (nonatomic, retain) CPTScatterPlot *myLine;
@property (nonatomic, retain) CPTGraph *graph;

    -(void) configureHorizontalLine
    {
        // 1 - Create plot space
        CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) self.graph.defaultPlotSpace;

        // 2 - Create the plot
        self.myLine = [[CPTScatterPlot alloc] init];
        self.myLine.dataSource = self;
        self.myLine.identifier = @"myLine";

        CPTColor *myPlotColor = [CPTColor redColor];
        [self.graph addPlot:self.myLine toPlotSpace:plotSpace];

        // 3 - Create styles
        CPTMutableLineStyle *myPlotLineStyle = [self.myLine.dataLineStyle mutableCopy];

        myPlotLineStyle.dashPattern=[NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:3],nil];  //dashed line

        myPlotLineStyle.lineWidth = 1;
        myPlotLineStyle.lineColor = myPlotColor;
        self.myLine.dataLineStyle = myPlotLineStyle;
    }
同样,在
CPTPlotDataSource
方法中,您必须执行以下检查以识别线图:

if ([[plot identifier] isEqual:@"myLine"])

这就是我在这种情况下使用的方法:

@property (nonatomic, retain) CPTScatterPlot *myLine;
@property (nonatomic, retain) CPTGraph *graph;

    -(void) configureHorizontalLine
    {
        // 1 - Create plot space
        CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) self.graph.defaultPlotSpace;

        // 2 - Create the plot
        self.myLine = [[CPTScatterPlot alloc] init];
        self.myLine.dataSource = self;
        self.myLine.identifier = @"myLine";

        CPTColor *myPlotColor = [CPTColor redColor];
        [self.graph addPlot:self.myLine toPlotSpace:plotSpace];

        // 3 - Create styles
        CPTMutableLineStyle *myPlotLineStyle = [self.myLine.dataLineStyle mutableCopy];

        myPlotLineStyle.dashPattern=[NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:3],nil];  //dashed line

        myPlotLineStyle.lineWidth = 1;
        myPlotLineStyle.lineColor = myPlotColor;
        self.myLine.dataLineStyle = myPlotLineStyle;
    }
同样,在
CPTPlotDataSource
方法中,您必须执行以下检查以识别线图:

if ([[plot identifier] isEqual:@"myLine"])

这就是我在这种情况下使用的方法:

@property (nonatomic, retain) CPTScatterPlot *myLine;
@property (nonatomic, retain) CPTGraph *graph;

    -(void) configureHorizontalLine
    {
        // 1 - Create plot space
        CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) self.graph.defaultPlotSpace;

        // 2 - Create the plot
        self.myLine = [[CPTScatterPlot alloc] init];
        self.myLine.dataSource = self;
        self.myLine.identifier = @"myLine";

        CPTColor *myPlotColor = [CPTColor redColor];
        [self.graph addPlot:self.myLine toPlotSpace:plotSpace];

        // 3 - Create styles
        CPTMutableLineStyle *myPlotLineStyle = [self.myLine.dataLineStyle mutableCopy];

        myPlotLineStyle.dashPattern=[NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:3],nil];  //dashed line

        myPlotLineStyle.lineWidth = 1;
        myPlotLineStyle.lineColor = myPlotColor;
        self.myLine.dataLineStyle = myPlotLineStyle;
    }
同样,在
CPTPlotDataSource
方法中,您必须执行以下检查以识别线图:

if ([[plot identifier] isEqual:@"myLine"])

您应该再添加两个表示两条水平线的绘图。感谢alot Stanley,我如何在图形上绘制虚线?我在有虚线的地方添加了代码,但使用相同的方法可以获得虚线。您应该再添加两个表示两条水平线的绘图。感谢alot Stanley,如何在图形上绘制虚线?我在有虚线的地方添加了代码,但使用相同的方法可以得到虚线。您应该再添加两个表示两条水平线的绘图。非常感谢Stanley,我如何在图形上绘制虚线?我在有虚线的地方添加了代码,但使用相同的方法可以得到虚线。您应该再添加两个表示两条水平线的绘图。非常感谢Stanley,我如何在图形上绘制虚线?我在有虚线的地方添加了代码,但使用相同的方法可以得到虚线。