Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | allow for column access in user-supplied function |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | master | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
88737e42c971e9fcdcca3aca9cf04394 |
| User & Date: | jack 2024-09-19 06:08:15 |
Context
|
2024-09-19
| ||
| 06:21 | demo: don't access internal symbols check-in: cf0910f19d user: jack tags: master, trunk | |
| 06:08 | allow for column access in user-supplied function check-in: 88737e42c9 user: jack tags: master, trunk | |
|
2024-05-14
| ||
| 10:45 | add a definition of done check-in: 7b66e5d647 user: jack tags: master, trunk | |
Changes
Changes to Code/dataset-and-aesthetics.lisp.
| ︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
:label "label"
:align-x "align-x"
:align-y "align-y"))
(defparameter *default-line-style* (c:make-line-style :thickness 3))
(defparameter *default-text-style* c:*default-text-style*)
(defun make-mapping-fn (aesthetics dataset)
(loop with head = (dataset-head dataset)
with cont = (gensym "CONT")
with raw-point = (gensym "RAW-POINT")
with point-values = nil
with position = nil
for (aesthetic source) on aesthetics by #'cddr
| > > > > > > > > > > > > > | 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 |
:label "label"
:align-x "align-x"
:align-y "align-y"))
(defparameter *default-line-style* (c:make-line-style :thickness 3))
(defparameter *default-text-style* c:*default-text-style*)
(defun make-get-value-fn (dataset)
(let ((headers (dataset-head dataset)))
(lambda (raw-point column-name)
(loop for val in (point-values raw-point)
for col in headers
when (string= col column-name)
return val))))
;;; Try doing that in C punk! :-)
(defvar *get-value-fn*)
(defun get-value (raw-point column-name)
(funcall *get-value-fn* raw-point column-name))
(defun make-mapping-fn (aesthetics dataset)
(loop with head = (dataset-head dataset)
with cont = (gensym "CONT")
with raw-point = (gensym "RAW-POINT")
with point-values = nil
with position = nil
for (aesthetic source) on aesthetics by #'cddr
|
| ︙ | ︙ | |||
97 98 99 100 101 102 103 | (defun bind-data (aesthetics dataset &key (class <mapped-data>)) (make-instance class :dataset dataset :aesthetics aesthetics)) ;;; Binding data conses a new vector so it may be potentially space and time ;;; consuming operation. We hide that behind the protocol so an alternate ;;; appraoch is possible. (define-class <mapped-data> () | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | (defun bind-data (aesthetics dataset &key (class <mapped-data>)) (make-instance class :dataset dataset :aesthetics aesthetics)) ;;; Binding data conses a new vector so it may be potentially space and time ;;; consuming operation. We hide that behind the protocol so an alternate ;;; appraoch is possible. (define-class <mapped-data> () (dataset get-value-fn aesthetics mapping-fn data-array)) ;;; FIXME do all aesthetics belong to a row? line-style applies to multiple ;;; points, align-x/y may be a geom property etc. Think about it. Moreover what ;;; happens when we draw a line between two points with different line styles? (define-class <row> () (x y shape ink ink* line-style text-style label align-x align-y xrange yrange) |
| ︙ | ︙ | |||
159 160 161 162 163 164 165 |
(vector-push-extend (slot-value point column-name) vector))
vector))
(defmethod map-dataset-points (fun (object <mapped-data>))
(map nil fun (data-array object)))
(defmethod initialize-instance :after ((obj <mapped-data>) &key dataset aesthetics)
| > | > | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
(vector-push-extend (slot-value point column-name) vector))
vector))
(defmethod map-dataset-points (fun (object <mapped-data>))
(map nil fun (data-array object)))
(defmethod initialize-instance :after ((obj <mapped-data>) &key dataset aesthetics)
(let ((*get-value-fn* (make-get-value-fn dataset))
(mapping-fn (make-mapping-fn aesthetics dataset)))
(let ((array (make-array '(0) :adjustable t :fill-pointer t)))
(do-points (point dataset)
(vector-push-extend (funcall mapping-fn #'<row> point) array))
(setf (get-value-fn obj) *get-value-fn*
(mapping-fn obj) mapping-fn
(data-array obj) array))))
|
Changes to Code/packages.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 |
(defpackage #:eu.turtleware.polyclot
(:use)
(:export #:polyclot
#:<polyclot>
#:<theme>
;; Layers
#:<layer> ; superclass of all geoms
#:<geom-point>
#:<geom-line>
#:<geom-bar>
;; Position adjustments
#:<position-identity> #:<position-jitter> #:<position-dodge> #:<position-stack> #:<position-fill>
#:+position-identity+ #:+position-jitter+ #:+position-dodge+ #:+position-stack+ #:+position-fill+
;; Coordinates
#:<coord-cartesian>
;; Scales
#:make-scale
;; Operations
#:stat-data
;; Utilities
#:make-range #:make-range*
))
(defpackage #:eu.turtleware.polyclot.implementation
| > > > > | 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 |
(defpackage #:eu.turtleware.polyclot
(:use)
(:export #:polyclot
#:<polyclot>
#:<theme>
;; Dataset and aesthetics
#:group-by #:get-value
;; Layers
#:<layer> ; superclass of all geoms
#:<geom-point>
#:<geom-line>
#:<geom-bar>
;; Position adjustments
#:<position-identity> #:<position-jitter> #:<position-dodge> #:<position-stack> #:<position-fill>
#:+position-identity+ #:+position-jitter+ #:+position-dodge+ #:+position-stack+ #:+position-fill+
;; Coordinates
#:<coord-cartesian>
;; Scales
#:make-scale
;; Faceting
#:<faceting-null> #:<faceting-wrap> #:<faceting-grid>
;; Operations
#:stat-data
;; Utilities
#:make-range #:make-range*
))
(defpackage #:eu.turtleware.polyclot.implementation
|
| ︙ | ︙ |
Changes to Demo/demo.lisp.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 |
(<polyclot>
:title "Multiple layers"
:dataset +data/sinus+
:coords (<coord-cartesian> :ylim (make-range -200 200))
:aesthetics (list :x "x"
:y "y"
:ink "ink"
| > > | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
(<polyclot>
:title "Multiple layers"
:dataset +data/sinus+
:coords (<coord-cartesian> :ylim (make-range -200 200))
:aesthetics (list :x "x"
:y "y"
:ink "ink"
:line-style (lambda (raw-point)
(let ((x (i::get-value raw-point "x")))
(make-line-style :thickness (/ (sqrt (abs x)) 3)))))
:layers (list (<geom-line>)
(<geom-point> :aesthetics
(list :ink c:+red+
:line-style (make-line-style :thickness 5)))))
"Three layers illustrating mapping and multiple layers.")
(define-demo-plot *test2*
|
| ︙ | ︙ |
Changes to README.org.
| ︙ | ︙ | |||
173 174 175 176 177 178 179 | should be for now considered to be destructive. Finally we estabilish local coordinates with the macro ~with-coords~ and call ~plot-geom~ which goes through the dataset and does the drawing. ToDo: - [X] <cartesian> defaults to the screen orientation (should be graphics) | > | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | should be for now considered to be destructive. Finally we estabilish local coordinates with the macro ~with-coords~ and call ~plot-geom~ which goes through the dataset and does the drawing. ToDo: - [X] <cartesian> defaults to the screen orientation (should be graphics) - [ ] dataset and aesthetics - [ ] <row> is an instance with fixed slots, we want to extend it (a vector?) - [-] all geoms are very primitive often not even using relevant aes - [X] <geom-point> - [X] <geom-line> - [X] <geom-bar> - [ ] provide extra polishing(!) - [7/9] implementation of scales and guides - [X] basic framework for scales is in place already |
| ︙ | ︙ | |||
246 247 248 249 250 251 252 253 254 255 256 257 258 259 | - [2022-11-08 Tue] moved the repository fossil.turtleware.eu/polyclot - [2022-11-16 Wed] implemented binned scale (and fixed scale mapping) - [2022-12-11 nie] improvements to scales, a simple listener tool (demo) - [2022-12-13 wto] add colors, initial render of the color scale - [2022-12-14 śro] position adjustment (dodge) - [2023-05-17 Wed] the architecture has been changed to account for faceting - [2024-05-08 Wed] resuming development (almost a year! In train after els'24) ** Faceting Facets are being implemented after a single plot abstraction has been defined and that demands some architectural changes. Let's start with a description: Faceting is an operation of splitting datasets into a few separate sets that are | > > > > > > > > > > > > > > > > > > > | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
- [2022-11-08 Tue] moved the repository fossil.turtleware.eu/polyclot
- [2022-11-16 Wed] implemented binned scale (and fixed scale mapping)
- [2022-12-11 nie] improvements to scales, a simple listener tool (demo)
- [2022-12-13 wto] add colors, initial render of the color scale
- [2022-12-14 śro] position adjustment (dodge)
- [2023-05-17 Wed] the architecture has been changed to account for faceting
- [2024-05-08 Wed] resuming development (almost a year! In train after els'24)
- [2024-09-19 Thu] when mapping allow access by user function to column by name
** Dataset and aesthetics
Currently we allow for the user to map aesthetics by name (a string), arbitrary
function (must be a function, not a function designator), and as a constant.
When the user passes a function, then it should accept as an argument raw
point. This function can call in its dynamic context the function GET-VALUE.
For example
#+begin_src lisp
:aesthetics (list :x "x"
:y "y"
:ink "ink"
:line-style (lambda (raw-point)
(let ((x (get-value raw-point "x")))
(make-line-style :thickness (/ (sqrt (abs x)) 3)))))
#+end_src
** Faceting
Facets are being implemented after a single plot abstraction has been defined
and that demands some architectural changes. Let's start with a description:
Faceting is an operation of splitting datasets into a few separate sets that are
|
| ︙ | ︙ |