I want to do simple graphing routines in Tcl/Tk like scatter plot, x-y plot, histograms. I am using Tcl/Tk 8.5.7. I found in Tcler's wiki that there are few options such as BLT which is not supported in Tcl/Tk 8.5+
Is there any Tcl/Tk interface to gnuplot
or any widget to accomplish graphing?
Please let me know about the choices for graphing routines in Tcl/Tk.
Gnuplot can indeed produce output that Tcl/Tk can consume. This page on the Tcler's Wiki describes how (though with some extra complexity because it is doing animations). Here's a simplified version:
package require Tk
eval [exec gnuplot << "
set term tk
plot x*x
"]
pack [canvas .c]
gnuplot .c
The gnuplot
command is created by eval
uating the output that the gnuplot program produced. This is a little bit tricky, especially if you're wanting to do multiple plots (hint: use namespaces) but it is pretty simple to use.