-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.lisp
181 lines (144 loc) · 3.37 KB
/
main.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
;;;; scatter.lisp - A collection of scatter plotting
;;;
;;; This code has been placed in the Public Domain. All warranties
;;; are disclaimed.
;;;
;;; This file is composed of a collection of exampeles of plotting.
;;; Here's codes are mainly deal scatter plotting.
(in-package :cl-user)
(defpackage :kai-example
(:use :cl)
(:import-from :kai
:title
:line
:pie
:box
:heatmap
:contour
:line3d
:surface
:fillarea
:marker
:marker3d
:xaxis
:yaxis
:show)
(:export :line
:marker-example
:pie-chart
:sunburst-chart
:heatmap-chart
:box-chart
:contour-chart
:line3d
:marker3d-example
:surface-chart))
(in-package :kai-example)
;;;; Parameters
;;;
;;; These are parameters to plot in the figure.
(defparameter x-data-index
(loop for i from 0 below 10
collect i))
(defparameter x-data-random
(loop for i from 0 below 100
collect (random 10.0)))
(defparameter y-data-10
(loop for i from 0 below 10
collect (random 10.0)))
(defparameter y-data-100
(loop for i from 0 below 100
collect (random 10.0)))
(defparameter z-data-100
(loop for i from 0 below 100
collect (random 10.0)))
(defparameter pie-label
'("Residential" "Non-Residential" "Utility"))
(defparameter pie-data
'(19 26 55))
(defparameter box-data
(loop :repeat 50
:collect (random 100.0)))
(defparameter heatmap-data
(loop :repeat 100
:collect (loop :repeat 100
:collect (random 10.0))))
(defparameter contour-data
(loop :repeat 20
:collect (loop :repeat 20
:collect (random 10.0))))
;;;; Basic plotting
;;;
;;; Line and scatter
(defun line-chart ()
(line x-data-index
y-data-10)
(title "Line plot example")
(xaxis (list :|title| "X axis"))
(yaxis (list :|title| "Y axis"))
(show))
(defun marker-example ()
(marker x-data-random
y-data-100
:size 20)
(title "Marker plot example")
(show))
(defun fill-chart ()
(fillarea '(1 2 3)
'(2 1 3)
'(5 2 7)
:color :aqua)
(title "Fill chart with line plotting")
(show))
;;;; Pie chart
;;;
;;; pie cahrt with labels
(defun pie-chart ()
(pie pie-data pie-label)
(title "Pie chart example")
(show))
;;;; Box
;;;
;;; box plots example
(defun box-chart ()
(box box-data)
(title "Box chart example")
(show))
;;;; Heatmap
;;;
;;; heatmap example
(defun heatmap-chart ()
(heatmap heatmap-data
:showscale t)
(title "Heatmap example")
(show))
;;;; Contour
;;;
;;; Contour example
(defun contour-chart ()
(contour contour-data
:showscale t)
(title "Contour example")
(show))
;;;; Scatter3D
;;;
;;; scatter3d plots: line and marker
(defun line3d-example ()
(line3d x-data-random
y-data-100
z-data-100)
(title "Line3D plot example")
(show))
(defun marker3d-example ()
(marker3d x-data-random
y-data-100
z-data-100)
(title "Marker3D plot example")
(show))
;;;; Surface
;;;
;;; surface chart-example
(defun surface-chart ()
(surface contour-data)
(title "Surface chart example")
(show))