Plot coordinate pairs: Difference between revisions

(→‎{{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, "Place " + str$((i * 40) + 25) + " 440"
Print #gwin, "|" + str$(i)
Next i
 
For i = 0 To 20 Step 29
PrintREAD #gwin,tmp: "Place 1 " + str$y(417 - (i) *= 20))tmp
Print #gwin, "|" +Right$(" " + str$(i * 10), 3) + "-"
Next i
 
'Plotting coordinate pairs a la Graphic Window - Style
WindowHeight = 500
WindowWidth = 500430
Open "Plot coordinate pairs" For GraphicsGraphics_nsb_nf As #gwin
Print #gwin, "trapclose [quit.gwin]"
Print #gwin, "Color Black; Down"
 
'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)
Print #gwin, "|.Go -18"
Print #gwin, "|"; + str$(i)x
Next
 
#gwin "turn 90"
For y = 0 To 200 Step 20
#gwin "place ";sx(0);" ";sy(y)
Print #gwin, "FlushGo -5"
#gwin "place ";0;" ";sy(y)
#gwin "|"; y
Next
 
#gwin "size 3"
For i = 0 To 9
Print #gwin, "Placeset " + str$(;sx(x(i) * 40) + 25) + ;" " + str$(418 - (418 * ;sy(y(i)/ 210)))
Print #gwin, "|."
Next i
 
Print #gwin, "Size 2Flush"
Print #gwin, "Place 25 415"
Print #gwin, "GoTo 25 14"
Print #gwin, "Place 25 415"
Print #gwin, "GoTo 387 415"
 
Print #gwin, "Flush"
Wait
 
[quit.gwin]
Close #gwin
End </lang>
 
'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}}==
Anonymous user