|
|
|
|
|
|
|
|
|
|
|
|
|
CAREFUL!!! Since I have no control over where you store the gnuplot control and data file on your system, you must make SURE(!!!!) that the references to those files --both in your program and in the gnuplot control file-- are correct. If you point gnuplot to the wrong file or into oblivion, it will not work correctly.
Public Class Gnuplot
Shared Sub Main()
Dim control_file As String = "C:\TEMP\gnuplot_controlfile"
do_the_plot(control_file)
End Sub
Shared Sub do_the_plot(ByRef control_file As String)
Dim winroot As String
Dim strCmdLine As String
Dim strCmdParam As String
winroot = System.Environment.GetEnvironmentVariable("SystemRoot")
strCmdLine = winroot + "\system32\cmd"
strCmdParam = "/C C:\""Program Files""\gnuplot\gp373w32\pgnuplot /noend " + control_file
Try
System.Diagnostics.Process.Start(strCmdLine, strCmdParam)
Catch E As Exception
Console.WriteLine(E.Message)
End Try
End Sub
End Class
In summary, from out of VB, we build a command to be executed by the command-line interpreter, then call the OS to start the command-line interpreter, handing it over the command to run inside the command-line interpreter... Makes sense?
Also, in the actual plot, note the gap in the curve for variable 'third.' Compare this with the 'NaN' entries in the data file.
Note that when gnuplot starts, it also starts a gnuplot interpreter window.
Although in our case we'll very likely not make much use of this,
you can use the menus in this window to fine tune the graph. You can also
issue additional gnuplot commands through the interpreter.
Note that when we invoke gnuplot through a console application, gnuplot
gets started from a (DOS) command shell that stays on the screen until we quit
gnuplot. However, if you instead use the techniques learned in the lesson
on VB.Net
Visual Programming and launch the application from a Windows application,
the command-line window does not show. To practice this, try writing a tiny Windows application with a form
with but a single button called 'Plot.' Define an event handler for this
button and let the event handler call the do_plot subroutine.