Prev: Need help on tablelist
Next: TCL exec
From: Richard Owlett on 23 Jul 2007 08:17 Uwe Klein wrote: > Richard Owlett wrote: > >> Uwe Klein wrote: >> >>> Richard Owlett wrote: >>> >>>> I've downloaded a current version of gnuplot and it plots my data >>>> nicely. I didn't find a interface to Tcl however.[except one that >>>> will continuously rotate the plot thru various views]. My OS is WinXP. >>>> >>> >>> gnuplot has a terminal driver for the Tk canvas. >>> >>> in a tcl shell do >>> >>> #start >>> package require Tk >>> >>> set gpcmds " >>> set terminal tkcanvas >>> plot sin(x) >>> " >>> >>> set canvcmds [ exec gnuplot << $gpcmds ] >>> >>> eval $canvcmds >>> >>> canvas .c ; pack .c >>> >>> gnuplot .c >>> >>> #end >>> >> >> I had to modify the code to reflect path to executable and its name. >> >> package require Tk >> set gpcmds " >> set terminal tkcanvas >> plot sin(x) >> " >> set canvcmds [ exec "G:\\gnuplot\\bin\\pgnuplot" << $gpcmds ] >> eval $canvcmds >> canvas .c ; pack .c >> pgnuplot .c >> >> In response to the last line I receive >> >> invalid command name "gnuplot" >> >> >> What is my problem? >> I am using ActiveStates distribution under WinXP Pro SP2. >> > print the content of $canvcmds to the screen or a printer > the gnuplot output is essentially a script that defines > a couple of procs. > > proc gnuplot can { > ..................... > # lots of [expr] and > # [$can create ...] stuff > } > proc gnuplot_plotarea {} { > ........... > # returns the bbbox of the plot > } > proc gnuplot_axisranges {} { > .............. > # returns the x and y scale range and the actual used range > } > > either you made some typing mistake or the [eval] went astray. > > uwe Printing $canvcmds gave a blank line until I changed set canvcmds [ exec "G:\\gnuplot\\bin\\pgnuplot" << $gpcmds ] to set canvcmds { exec "G:\\gnuplot\\bin\\pgnuplot" << $gpcmds } It still doesn't work. Has anyone else attempted to do this on a Windows(tm) system. I notice that the help file lists many cautions about using exec on Windows(tm) systems.
From: suchenwi on 23 Jul 2007 09:01 On 23 Jul., 14:17, Richard Owlett <rowl...(a)atlascomm.net> wrote: > Printing $canvcmds gave a blank line until I changed > set canvcmds [ exec "G:\\gnuplot\\bin\\pgnuplot" << $gpcmds ] > to > set canvcmds { exec "G:\\gnuplot\\bin\\pgnuplot" << $gpcmds } > That does something very differently, and probably not the thing wanted. > It still doesn't work. Has anyone else attempted to do this on a > Windows(tm) system. I notice that the help file lists many cautions > about using exec on Windows(tm) systems.- I just downloaded, on a Win XP box, http://gnuplot.sourceforge.net/development/binaries/gp41-July18_2006-winbin.zip and can confirm that the exec for that particular pgnuplot.exe returns "".
From: Uwe Klein on 27 Jul 2007 05:48
Esa Heikkinen wrote: > Richard Owlett kirjoitti: > >> Uwe Klein wrote: >> >>> Richard Owlett wrote: >>> >>>> I've downloaded a current version of gnuplot and it plots my data >>>> nicely. I didn't find a interface to Tcl however.[except one that >>>> will continuously rotate the plot thru various views]. My OS is WinXP. >>>> >>> >>> gnuplot has a terminal driver for the Tk canvas. >>> >>> in a tcl shell do >>> >>> #start >>> package require Tk >>> >>> set gpcmds " >>> set terminal tkcanvas >>> plot sin(x) >>> " >>> >>> set canvcmds [ exec gnuplot << $gpcmds ] >>> >>> eval $canvcmds >>> >>> canvas .c ; pack .c >>> >>> gnuplot .c >>> >>> #end >>> >> >> I had to modify the code to reflect path to executable and its name. >> >> package require Tk >> set gpcmds " >> set terminal tkcanvas >> plot sin(x) >> " >> set canvcmds [ exec "G:\\gnuplot\\bin\\pgnuplot" << $gpcmds ] >> eval $canvcmds >> canvas .c ; pack .c >> pgnuplot .c >> >> In response to the last line I receive >> >> invalid command name "gnuplot" >> >> >> What is my problem? >> I am using ActiveStates distribution under WinXP Pro SP2. >> > > Hi > > I am little surprised. Is it really possible to run gnuplot inside TCL > in canvas ? I was thinking the gnuplot was only "external" program. No, and yes it is. you [exec] gnuplot with the commands of your choice. In this case you advise gnuplot to use its "tkcanvas" driver for output. ( Tcl as in Tool Control Language ;-) The output is a script that creates three procs. [gnuplot] containing all the commands to create your plot as elements on a tkcanvas. ( see prev posting for details ) [gnuplot_plotarea] to know about the bbox and [gnuplot_axisranges] to know about used and plotted axis ranges. proc gnuplot can { ..................... # lots of [expr] and # [$can create ...] stuff } proc gnuplot_plotarea {} { ........... # returns the bbbox of the plot } proc gnuplot_axisranges {} { .............. # returns the x and y scale range and the actual used range } > > > --- > Esa uwe |