tags:

views:

80

answers:

2

Can someone give me some good tutorials on Creating a 2D plot on IPhone given a variable number of x,y coordinates?

A: 

You can do this with the CGContextAddLineToPoint method.

http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/dq_paths.html#//apple_ref/doc/uid/TP30001066-CH211

Shyam
I dont really see an example on there. Dont really understand how to interpret that in making a 2D graph. Can you please help?
Nick LaMarca
In an iPhone application, you set up a UIView object to draw path with the CGContextAddLineToPoint. That page includes a lot of information and you should start at the beginning. Its not that hard.
Shyam
+1  A: 

If you're looking for something beyond just plotting the points, check out the open source Core Plot framework for Mac and iPhone. It's still a young project, but it can handle a scatter plot (with or without lines between the points) along with labeled axes just fine. There are a number of example programs included with the framework that demonstrate some of its capabilities.

Eric Skroch
+1, we used Core Plot to great effect on my last iPhone project - it's definitely not super polished but it's pretty well-architected
Daniel DiPaolo
I checked that out but there isnt any sample code on how to make a 2D graph. Do you have any good tutorials?
Nick LaMarca
Look at CPTestApp in the examples folder for scatter plot demos. The Mac, iPhone, and iPad versions all use them, as do several of the other examples. Everything in Core Plot is 2D only right now. If you want to only plot the points and not a line chart, be sure to set a plot symbol (either on the plot itself or using the datasource) and set the line style for the plot to nil.
Eric Skroch