1 Attachment(s)
Plotting points in picturebox
I've searched for how to plot points in a picturebox and then join then (a mini graph) without any luck.
Does anyone have an example to get me started?
Attached is what I'm trying to achieve. In the example values could be..
1. 50
2. 80
3. 65
4. 55
5. 95
Re: Plotting points in picturebox
But to plot points you need two values. One x and one y. You only supplied one value.
Re: Plotting points in picturebox
my mistake. Does this help?
10,50
20,80
30,65
40,55
50,95
Re: Plotting points in picturebox
OK. If you store those coordinates you could just use the Line method to draw a line from one point to the next.
VB Code:
Picture1.Line (10, 50)-(20, 80)
Of course you need to change the ScaleMode of the picture box. Also since the (0, 0) corner is the upper left corner instead of the lower left you might want to recalculate the second point.
VB Code:
Picture1.Line (10, Picture1.ScaleHeight - 50)-(20, Picture1.ScaleHeight - 80)
Re: Plotting points in picturebox
Thanks, i'll see how I go.
Re: Plotting points in picturebox
Thanks Joacim, got the basics using the below and will now modify to meet my requirements. :thumb:
VB Code:
Private Sub Form_Load()
Picture1.ScaleHeight = 100
Picture1.ScaleWidth = 100
Picture1.Line (10, 50)-(20, 80)
Picture1.Line (20, 80)-(30, 65)
Picture1.Line (30, 65)-(40, 55)
Picture1.Line (40, 55)-(50, 95)
End Sub