fricas
(1) -> <spad>
fricas
)abbrev package PLOTLY Plotly
++ Author: Kurt Pagani
++ Date Created: Sat Jul 14 01:52:32 CEST 2018
++ License: BSD
++ References:
++ Description:
++
Plotly(R) : Exports == Implementation where
R:Join(Ring,ConvertibleTo Float,ConvertibleTo String)
LR ==> List R
STR ==> String
MSC ==> MoreSystemCommands
Exports == with
format : (STR,STR) -> STR
format : (STR,List STR) -> STR
convert : LR -> STR
plotly : (LR,LR) -> Void
plotly2html : (LR,LR) -> Void
Implementation == add
plotly_js:String:="https://cdn.plot.ly/plotly-latest.min.js"
--plotly_js:String:="'file:///...plotly-latest.min.js'"
loc:String:="C:/Users/kfp" -- where to place the html file
title:="titleXY"
fname:="plot"
tmpl:="~{<!DOCTYPE html>~%_
<head>~%_
<title>~a</title>~%_
<disabled script src=~a><disabled /script>~%_
</head>~%_
<body>~%_
<div id=~a style=width:600px;height:250px;></div>~%_
<disabled script>~%_
DIVDOM=document.getElementById('~a');~%_
Plotly.plot( DIVDOM, [{~%_
x: ~a,~%_
y: ~a }], {~%_
margin: { t: 0 } } );~%_
<disabled /script>~%_
</body>~%_
</html>~}"
format(s:STR,t:STR):STR == string FORMAT('NIL,s,t)$Lisp
-- format("<title>~a</title>","'Hello'")
format(s:STR,l:List STR) == string FORMAT('NIL,s,l)$Lisp
-- FORMAT('NIL,"~{~a ~a ~a ~}",["x","y","z"])$Lisp
-- format("~{~a ~a ~a ~}",["One", "two", "three"])
convert(X:LR):String ==
if R has FloatingPointSystem then
ls:List String:=[toString(x,8) for x in X]
else
ls:List String:=[convert(x)@String for x in X]
format("[~{~a~^, ~}]" ,ls)
-- convert([1.222,3.444])$Plotly(Float)
-- convert([1,3])$Plotly(INT)
plotly(X:LR,Y:LR):Void ==
not #X=#Y => error "#X ~= #Y !"
x:STR:=convert(X)
y:STR:=convert(Y)
f:FileName:=new(loc,fname,"html")$FileName
tf:TextFile:=open(f,"output")
put(s) ==> writeLine!(tf,s)
ls:List STR:=[title,plotly_js,title,title,x,y]
put format(tmpl,ls)
close!(tf)
Void()
plotly2html(X:LR,Y:LR):Void ==
not #X=#Y => error "#X ~= #Y !"
x:STR:=convert(X)
y:STR:=convert(Y)
put(s) ==> output(s)$OutputPackage
ls:List STR:=[title,plotly_js,title,title,x,y]
put format(tmpl,ls)
Void()</spad>
fricas
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3265706449736266503-25px001.spad
using old system compiler.
PLOTLY abbreviates package Plotly
------------------------------------------------------------------------
initializing NRLIB PLOTLY for Plotly
compiling into NRLIB PLOTLY
****** Domain: R already in scope
****** Domain: R already in scope
compiling exported format : (String,String) -> String
Time: 0 SEC.
compiling exported format : (String,List String) -> String
Time: 0 SEC.
compiling exported convert : List R -> String
****** Domain: R already in scope
augmenting R: (FloatingPointSystem)
Time: 0.01 SEC.
compiling exported plotly : (List R,List R) -> Void
processing macro definition put s ==> writeLine!(tf,s)
Time: 0 SEC.
compiling exported plotly2html : (List R,List R) -> Void
processing macro definition put s ==> (Sel (OutputPackage) output) s
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |Plotly| REDEFINED
;;; *** |Plotly| REDEFINED
Time: 0 SEC.
Cumulative Statistics for Constructor Plotly
Time: 0.03 seconds
finalizing NRLIB PLOTLY
Processing Plotly for Browser database:
--------constructor---------
--->-->Plotly((format ((String) (String) (String)))): Not documented!!!!
--->-->Plotly((format ((String) (String) (List (String))))): Not documented!!!!
--->-->Plotly((convert ((String) (List R)))): Not documented!!!!
--->-->Plotly((plotly ((Void) (List R) (List R)))): Not documented!!!!
--->-->Plotly((plotly2html ((Void) (List R) (List R)))): Not documented!!!!
; compiling file "/var/aw/var/LatexWiki/PLOTLY.NRLIB/PLOTLY.lsp" (written 02 NOV 2024 02:50:13 AM):
; wrote /var/aw/var/LatexWiki/PLOTLY.NRLIB/PLOTLY.fasl
; compilation finished in 0:00:00.012
------------------------------------------------------------------------
Plotly is now explicitly exposed in frame initial
Plotly will be automatically loaded when needed from
/var/aw/var/LatexWiki/PLOTLY.NRLIB/PLOTLY
fricas
)set output tex off
fricas
)set output algebra on
plotly2html([i for i in 1..12],[i^2 for i in 1..12])
<!DOCTYPE html>
<head>
<title>titleXY</title>
<disabled script src=https:/
/cdn.plot.ly/plotly-latest.min.js><disabled /script>
</head>
<body>
<div id=titleXY style=width:600px;height:250px;></div>
<disabled script>
;
DIVDOM=document.getElementById('titleXY');
Plotly.plot( DIVDOM, [{
x: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
y: [1, 4, 9, 16, 25, 36, 49,
64, 81, 100, 121, 144] }], {
margin: { t: 0 } } );
<disabled /script>
</body>
</html>
Type: Void
- -- plotly([i for i in 1..12]?,[i^2 for i in 1..12]?)
- plotly([i::Float for i in 1..12]?,[sin(i::Float) for i in 1..12]?)
-- TODO: send to browser ...