Plot coordinate pairs: Difference between revisions

Content added Content deleted
(→‎{{header|C}}: EPS writer)
Line 422: Line 422:


=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==
First version writes directly to LB's concsole window.
<lang lb>
<lang lb>
'Plotting coordinate pairs MainWin - Style
'Plotting coordinate pairs MainWin - Style
Line 456: Line 457:
Next i
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
For i = 0 To 9
READ tmp: x( i) = tmp
Print #gwin, "Place " + str$((i * 40) + 25) + " 440"
Print #gwin, "|" + str$(i)
Next i
Next i


For i = 0 To 20 Step 2
For i = 0 To 9
Print #gwin, "Place 1 " + str$(417 - (i * 20))
READ tmp: y( i) = tmp
Print #gwin, "|" +Right$(" " + str$(i * 10), 3) + "-"
Next i
Next i


'Plotting coordinate pairs
WindowHeight = 500
WindowWidth = 430
Open "Plot coordinate pairs" For Graphics_nsb_nf As #gwin
#gwin "trapclose [quit.gwin]"
#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)
#gwin "Go -18"
#gwin "|"; x
Next

#gwin "turn 90"
For y = 0 To 200 Step 20
#gwin "place ";sx(0);" ";sy(y)
#gwin "Go -5"
#gwin "place ";0;" ";sy(y)
#gwin "|"; y
Next

#gwin "size 3"
For i = 0 To 9
For i = 0 To 9
Print #gwin, "Place " + str$((x(i) * 40) + 25) + " " + str$(418 - (418 * (y(i)/ 210)))
#gwin "set ";sx(x(i));" ";sy(y(i))
Print #gwin, "|."
Next i
Next i


Print #gwin, "Size 2"
#gwin "Flush"
Print #gwin, "Place 25 415"
Print #gwin, "GoTo 25 14"
Print #gwin, "Place 25 415"
Print #gwin, "GoTo 387 415"

Print #gwin, "Flush"
Wait
Wait


[quit.gwin]
[quit.gwin]
Close #gwin
Close #gwin
End </lang>
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}}==
=={{header|Mathematica}}==