Reputation: 425
I have a list of X,Y co-ordinates and I'd like to visualize these on my program. What function would be best to use? I will hard code in a base set of co-ordinates before expanding to read from a text file. I am able to do all this, but all the functions I have seen on the net are only for 2 x,y co-ordinates, my X,Y co-ordinates require around 10 or so plots. If anyone could help me out it would be greatly appreciated!
Upvotes: 0
Views: 146
Reputation: 225164
You'll need to use GDI+ and the Graphics
object. Basically, you'll override the OnPaint
method of any Control
, and draw your points somewhat like this:
Graphics g = e.Graphics;
Point p1 = new Point(20, 20);
Point p2 = new Point(50, 50);
g.DrawLine(Pens.Red, p1, p2);
g.FillEllipse(Pens.Red, p1.X - 2, p1.Y - 2, 4, 4);
g.FillEllipse(Pens.Red, p2.X - 2, p2.Y - 2, 4, 4);
... and so on. That particular example draws a line between coordinates (20, 20) and (50, 50) with a 4-pixel-diameter circle at each extremity.
Upvotes: 1