开发者

How to plot a scatterplot using numbers in core plot

I n开发者_运维技巧eed to draw a scatter plot with the given array of numbers in iPhone. How can I achieve this?


You just need to write a method which will returns an object of (NSNumber *) and takes NSInteger (it will be the index for which you want the value) as parameter. Inside this method you will retrieve the value from a specific index of your NSMutableArray.

Now step number 2) write the method as shown below. By this method the graph will know how many co - ordinates are to be plotted.

-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot {
    return (here you should call your method that will return the length of your array);
}

Step 3) This is the method to which your graph will look at for plotting a coordinate.

-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index {

    if (fieldEnum == CPScatterPlotFieldX)
    {
        return (value that you want to plot on X- axis. for example index);
    }
    else
    {
        return ( call your method you implemented in step 1) that will fetch a value from your array and pass (index) as parameter); // It will plot the value on the y-axis.
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜