zak
05-07-2010, 19:31
Hi
suppose there is a data produced by thinbasic to a file, and we want to plot it, there is a freeware program gnuplot can plot the data either in 2D or 3D perspective.
the site: http://www.gnuplot.info/
the Windows binaries built by Tatsuro Matsuoka can be downloaded from here: (updated today):
http://www.tatsuromatsuoka.com/gnuplot/Eng/winbin/
add to the path c:\gnuplot\binary , the first time you run gnuplot it may take 4 seconds, after that it will run smoothly.
it is better to run gnuplot over a file, but in the two examples below we will use the plotting instructions as parameters ; must be on one line separated by ";".
the first example:
https://sites.google.com/site/perlopengl/gnuplot1.png
Uses "console","OS"
Dim appName As String = "gnuplot.exe -e "
Dim appParameters As String = RawText
"plot sin(x)/x";
"pause mouse keypress";
End RawText
'you can use pause(5) to delay for 5 seconds
appParameters = Trim$(appParameters, Any $CR+$LF+$SPC+$TAB)
appParameters = Remove$(appParameters, Any $CR+$LF)
appName = appName & appParameters
Dim pID As Long
pID = OS_Shell(OS_Environ("COMSPEC") + " /C " & appName ,%OS_WNDSTYLE_NORMAL,%OS_SHELL_SYNC)
PrintL "--Press a key to kill " & appName & "--"
WaitKey
'---Now kill the process using its process id
OS_ProcessKillById(pID)
i have used RawText because i can't give this phrase as string parameter to gnuplot "plot sin(x)/x"; since i can't write it like ""plot sin(x)/x""; is it possible somehow??, any way RawText is handy.
the second example:
https://sites.google.com/site/perlopengl/gnuplot2.png
Uses "console","OS"
Dim appName As String = "gnuplot.exe -e "
Dim appParameters As String = RawText
"set key top left";
"set key box";
"plot [-pi:pi] sin(x) title 'sinusoid' with linespoints pointtype 5, cos(x) t 'cosine' w boxes lt 4";
"pause mouse keypress 'press a key In the active Window to exit'";
End RawText
appParameters = Trim$(appParameters, Any $CR+$LF+$SPC+$TAB)
appParameters = Remove$(appParameters, Any $CR+$LF)
appName = appName & appParameters
Dim pID As Long
pID = OS_Shell(OS_Environ("COMSPEC") + " /C " & appName ,%OS_WNDSTYLE_NORMAL,%OS_SHELL_SYNC)
PrintL "--Press a key to kill " & appName & "--"
WaitKey
'---Now kill the process using its process id
OS_ProcessKillById(pID)
references:
1-excellent tutorial:
http://t16web.lanl.gov/Kawano/gnuplot/index-e.html
2-Visualize your data with gnuplot:
http://www.ibm.com/developerworks/library/l-gnuplot/
3-Gnuplot in Action (August, 2009 | 396 pages):
http://www.manning.com/janert/
any improvements are welcome
regards
suppose there is a data produced by thinbasic to a file, and we want to plot it, there is a freeware program gnuplot can plot the data either in 2D or 3D perspective.
the site: http://www.gnuplot.info/
the Windows binaries built by Tatsuro Matsuoka can be downloaded from here: (updated today):
http://www.tatsuromatsuoka.com/gnuplot/Eng/winbin/
add to the path c:\gnuplot\binary , the first time you run gnuplot it may take 4 seconds, after that it will run smoothly.
it is better to run gnuplot over a file, but in the two examples below we will use the plotting instructions as parameters ; must be on one line separated by ";".
the first example:
https://sites.google.com/site/perlopengl/gnuplot1.png
Uses "console","OS"
Dim appName As String = "gnuplot.exe -e "
Dim appParameters As String = RawText
"plot sin(x)/x";
"pause mouse keypress";
End RawText
'you can use pause(5) to delay for 5 seconds
appParameters = Trim$(appParameters, Any $CR+$LF+$SPC+$TAB)
appParameters = Remove$(appParameters, Any $CR+$LF)
appName = appName & appParameters
Dim pID As Long
pID = OS_Shell(OS_Environ("COMSPEC") + " /C " & appName ,%OS_WNDSTYLE_NORMAL,%OS_SHELL_SYNC)
PrintL "--Press a key to kill " & appName & "--"
WaitKey
'---Now kill the process using its process id
OS_ProcessKillById(pID)
i have used RawText because i can't give this phrase as string parameter to gnuplot "plot sin(x)/x"; since i can't write it like ""plot sin(x)/x""; is it possible somehow??, any way RawText is handy.
the second example:
https://sites.google.com/site/perlopengl/gnuplot2.png
Uses "console","OS"
Dim appName As String = "gnuplot.exe -e "
Dim appParameters As String = RawText
"set key top left";
"set key box";
"plot [-pi:pi] sin(x) title 'sinusoid' with linespoints pointtype 5, cos(x) t 'cosine' w boxes lt 4";
"pause mouse keypress 'press a key In the active Window to exit'";
End RawText
appParameters = Trim$(appParameters, Any $CR+$LF+$SPC+$TAB)
appParameters = Remove$(appParameters, Any $CR+$LF)
appName = appName & appParameters
Dim pID As Long
pID = OS_Shell(OS_Environ("COMSPEC") + " /C " & appName ,%OS_WNDSTYLE_NORMAL,%OS_SHELL_SYNC)
PrintL "--Press a key to kill " & appName & "--"
WaitKey
'---Now kill the process using its process id
OS_ProcessKillById(pID)
references:
1-excellent tutorial:
http://t16web.lanl.gov/Kawano/gnuplot/index-e.html
2-Visualize your data with gnuplot:
http://www.ibm.com/developerworks/library/l-gnuplot/
3-Gnuplot in Action (August, 2009 | 396 pages):
http://www.manning.com/janert/
any improvements are welcome
regards