https://github.com/lepisma/plotly-cl
Common Lisp to plotly.js
https://github.com/lepisma/plotly-cl
common-lisp plotlyjs
Last synced: 3 months ago
JSON representation
Common Lisp to plotly.js
- Host: GitHub
- URL: https://github.com/lepisma/plotly-cl
- Owner: lepisma
- License: gpl-3.0
- Created: 2018-03-09T21:41:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-20T04:28:36.000Z (over 7 years ago)
- Last Synced: 2025-01-21T18:49:27.666Z (5 months ago)
- Topics: common-lisp, plotlyjs
- Language: Common Lisp
- Homepage:
- Size: 52.7 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
#+TITLE: plotly-cl
Plot stuff using ~plotly.js~ in Common Lisp.
We will reproduce the following chart from [[https://plot.ly/javascript/line-and-scatter/#data-labels-on-the-plot][here]].
[[file:./plot.png]]
JavaScript code is copied below. Lisp code follows.
#+BEGIN_SRC js
var trace1 = {
x: [1, 2, 3, 4, 5],
y: [1, 6, 3, 6, 1],
mode: 'markers+text',
type: 'scatter',
name: 'Team A',
text: ['A-1', 'A-2', 'A-3', 'A-4', 'A-5'],
textposition: 'top center',
textfont: {
family: 'Raleway, sans-serif'
},
marker: { size: 12 }
};var trace2 = {
x: [1.5, 2.5, 3.5, 4.5, 5.5],
y: [4, 1, 7, 1, 4],
mode: 'markers+text',
type: 'scatter',
name: 'Team B',
text: ['B-a', 'B-b', 'B-c', 'B-d', 'B-e'],
textfont : {
family:'Times New Roman'
},
textposition: 'bottom center',
marker: { size: 12 }
};var data = [ trace1, trace2 ];
var layout = {
xaxis: {
range: [ 0.75, 5.25 ]
},
yaxis: {
range: [0, 8]
},
legend: {
y: 0.5,
yref: 'paper',
font: {
family: 'Arial, sans-serif',
size: 20,
color: 'grey',
}
},
title:'Data Labels on the Plot'
};Plotly.newPlot('myDiv', data, layout);
#+END_SRC#+BEGIN_SRC common-lisp
(in-package :plotly-cl)(let ((trace-1 `((:x . #(1 2 3 4 5))
(:y . #(1 6 3 5 1))
(:mode . "markers+text")
(:type . "scatter")
(:name . "Team A")
(:text . ("A-1" "A-2" "A-3" "A-4" "A-5"))
(:textposition . "top center")
(:textfont . ((:family . "Raleway, sans-serif")))
(:marker . ((:size . 12)))))
(trace-2 `((:x . #(1.5 2.5 3.5 4.5 5.5))
(:y . #(4 1 7 1 4))
(:mode . "markers+text")
(:type . "scatter")
(:name . "Team B")
(:text . ("B-a" "B-b" "B-c" "B-d" "B-e"))
(:textposition . "bottom center")
(:textfont . ((:family . "Times New Roman")))
(:marker . ((:size . 12)))))
(layout `((:xaxis . ((:range . (0.75 5.25))))
(:yaxis . ((:range . (0 8))))
(:legend . ((:y . 0.5)
(:yref . "paper")
(:font . ((:family . "Arial, sans-serif")
(:size . 20)
(:color . "grey")))))
(:title . "Data Labels on the Plot"))))
(pl-plot (list trace-1 trace-2) :layout layout :width 1000 :height 500))
#+END_SRC