help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I use octave gnuplot to html5 canvas terminal?


From: Paul Perry
Subject: Re: How do I use octave gnuplot to html5 canvas terminal?
Date: Fri, 27 Jan 2012 09:55:30 -0500



On Fri, Jan 20, 2012 at 11:34 AM, Ben Abbott <address@hidden> wrote:
On Jan 20, 2012, at 11:25 AM, Paul Perry wrote:

> On Fri, Jan 20, 2012 at 9:49 AM, Ben Abbott <address@hidden> wrote:
>
> On Jan 20, 2012, at 8:26 AM, Paul Perry wrote:
>
> > On Fri, Jan 20, 2012 at 8:07 AM, Ben Abbott <address@hidden> wrote:
> >
> > On Jan 20, 2012, at 7:45 AM, Paul Perry wrote:
> >
> > > Hopefully one last request:  how do we pass additional arguments to the canvas terminal?  I'd like to pass a 'jsdir' string and 'name' parameter as in:
> > >
> > > set terminal canvas enhanced mousing size 1120,840 jsdir './js/' name 'file.js'
> > >
> > > drawnow() doesn't take these parameters.  I could not get the 'set' command to work:
> > >
> > > set(terminal,"canvas","jsdir","./js/","name","file.js","size","1120,840")
> > >
> > > hints?
> > >
> > > Thank you.
> >
> > You'll need to save the gnuplot commands and edit them yourself.
> >
> > What does the "jsdir './js/' name 'file.js'" part do ?
> >
> > Is this something that should be included by default ?
> >
> > Ben
> >
> >
> > By default the .js and .css files are set to "/tmp/gnuplot-some-dir/etc", requiring the html to be edited every time.  The jsdir parameter allows you to set the _javascript_ directory, in my case "./js/" .
> >
> > The "name" parameter outputs the canvas as a _javascript_ file which can then be included in a more complex html file.  This will allow us to just modify and include the canvas instead of re-editing the html file every time.   This change alone, would allow us to run the Octave commands and then just reload the html to view an interactive plot instead of modifying the octave output to gnuplot every time.
> >
> > Thx
>
> Ok, I understand. I don't see a good way to have Octave handle this. However, I do have a work around for you.
>
> I've attached a bash shell script that will fix the gnuplot terminal setting for you.
>
> To get the result you are looking for, create your plot and save the plotstream.
>
>        peaks ()
>        drawnow ("canvas", "/dev/null", false, "plotstream.gp")
>
> Then use the bash script to modify gnuplot terminal command in "plotstream.gp"
>
>        [status, output] = system ("add_js_to_canvas_terminal.sh");
>
> If you get an error, make sure the script is executable. From the terminal you can type ...
>
>        chmod 755 add_js_to_canvas_terminal.sh
>
> Finally, pass the plotstream through gnuplot to produce your html5 file.
>
>        [status, output] = system ("gnuplot plotstream.gp");
>
> My _javascript_ isn't set up the way yours is, so passing plotstream.gp through gnuplot produces an error for me. However, the terminal command matches the one you mentioned above. So this should work for you.
>
> Ben
>
> Thank you Ben!  I should of thought of that.  Can you attach the .sh file? I didn't see it. Thx
>

Opps, I forgot to attach it.

This works, with 2 changes:

the named js file in the set terminal command must not have a trailing filetype (just a name and no '.' after it) otherwise you get this error: "line 2: illegal _javascript_ function name"
and we need to set the output to the js filename.  apparently naming it only sets the variable in the js file, it doesn't output to that name.  My .sh now looks like this:

#! /bin/sh -ev
PLOTSTREAM=plotstream.gp
JSNAME=plotit
NEWTERM="set terminal canvas enhanced mousing size 1120,840 jsdir '.\/js\/' name '$JSNAME'"
sed -i '' -e "s/^set terminal canvas.*$/$NEWTERM/" $PLOTSTREAM
sed -i '' -e "s/^set output.*$/set output '$JSNAME.js'/" $PLOTSTREAM

Thanks, Paul.
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]