Drawing two plots together in jupyter/fricas?

50 views
Skip to first unread message

Alasdair McAndrew

unread,
Jun 18, 2016, 5:09:45 AM6/18/16
to fricas...@googlegroups.com
So, I've got FriCAS running in jupyter (thanks Kurt - superb work!), and I've compiled jupyter.spad to have the draw functions available.  Incidentally, why does this need to be done?  Can we have jDraw etc automatically available when a FriCAS session is started in jupyter?  But anyway, I wanted to plot two graphs on the same set of axes.  Ordinarily, this could be done, for example, as

plot([x^2-2,x^3-x],-1..2)

but a list of functions is not a legitimate input to jDraw.  So how can I plot two functions together?

Thanks,
Alasdair

--
http://www.facebook.com/alasdairmcandrew https://twitter.com/amca01

Kurt Pagani

unread,
Jun 18, 2016, 5:55:16 PM6/18/16
to fricas...@googlegroups.com
Hello Alasdair

Am 18.06.2016 um 11:09 schrieb Alasdair McAndrew:
> So, I've got FriCAS running in jupyter (thanks Kurt - superb work!), and
> I've compiled jupyter.spad to have the draw functions available.
> Incidentally, why does this need to be done?

Well, jupyter_fricas still is a construction site, especially regarding
plotting. Native 'draw/plot' doesn't work (yet) without X. At the moment
Gnuplot is used to provide some basic graphics.

If you have a look at the source code you'll immediatly recognize how
jDraw interfaces to GnuDraw:

jDraw(f,r) ==
gnuDraw(f,r,outFile)$GnuDraw
systemCommand(sysPcmd)$MoreSystemCommands
return pngFile::FileName

where sysPcmd:String := concat [sysGplt," ",gplOpts," ",outFile," >
",pngFile]

It's easy to write your own 'draw' function if you know how gnuplot
works. The new version 5 of Gnuplot has a 'set term canvas' option which
might be a better choice than 'png'.

I'm evaluating some other tools, e.g.
http://kfp.bitbucket.org/tmp/GLE.html or
http://jsxgraph.uni-bayreuth.de/wp/index.html, however, there is no
absolute winner yet. BTW if you know a suitable 3d interactive graphics
library in JavaScript, let me know.


> Can we have jDraw etc
> automatically available when a FriCAS session is started in jupyter?

You can insert a ")lib path/JUPYTER" into the startup file
"~/.fricas.input", for instance, or directly define your own functions
there.


> But
> anyway, I wanted to plot two graphs on the same set of axes. Ordinarily,
> this could be done, for example, as
>
> plot([x^2-2,x^3-x],-1..2)
>
> but a list of functions is not a legitimate input to jDraw. So how can I
> plot two functions together?

I'll look into this asap. I suppose one simply has to add another
instance of jDraw with first argument List(...) in jupyter.spad.

Just like in terminal:

(1) -> )system gnuplot -e "set term dumb; plot sin(x),cos(x)"



>
> Thanks,
> Alasdair
>
Reply all
Reply to author
Forward
0 new messages