Anonymous user
Plot coordinate pairs: Difference between revisions
→{{header|Liberty BASIC}}
(→{{header|C}}: EPS writer) |
|||
Line 422:
=={{header|Liberty BASIC}}==
First version writes directly to LB's concsole window.
<lang lb>
'Plotting coordinate pairs MainWin - Style
Line 456 ⟶ 457:
Next i
End
'Plotting coordinate pairs a la Graphic Window - Style▼
</lang>
WindowHeight = 500▼
The second version uses the more typical graphic window approach, and is written to enable easy adaptation to other data sets.
WindowWidth = 500▼
<lang lb>
Open "Plot coordinate pairs" For Graphics As #gwin▼
nomainwin
Print #gwin, "trapclose [quit.gwin]"▼
Print #gwin, "Color Black; Down"▼
DATA 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
DATA 2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0
For i = 0 To 9
READ tmp: x( i) = tmp
Print #gwin, "|" + str$(i)▼
Next i
For i = 0 To
Next i
▲WindowHeight = 500
'25, 418 is 0,0
global offsetX, offsetY, scaleX, scaleY
offsetX = 25: offsetY = 418
scaleX = 40: scaleY = 2
maxX = 9: maxY = 200
#gwin "line "; sx( maxX);" "; sy( 0);" "; sx( 0); " "; sy( 0)
#gwin "goto "; sx( 0); " "; sy( maxY)
For x = 0 To 9
#gwin "place ";sx(x);" ";sy(0)
Next
#gwin "turn 90"
For y = 0 To 200 Step 20
#gwin "place ";sx(0);" ";sy(y)
#gwin "place ";0;" ";sy(y)
#gwin "|"; y
Next
#gwin "size 3"
For i = 0 To 9
▲ Print #gwin, "|."
Next i
▲Print #gwin, "Flush"
Wait
[quit.gwin]
Close #gwin
End
'x, y to screen x, y
function sx(x)
sx = offsetX +x*scaleX
end function
function sy(y)
sy = offsetY-y*scaleY 'y is inverted
end function
</lang>
=={{header|Mathematica}}==
|