Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:designate package and exported symbols with strings
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 2cefd2078313a7ceafdaa827a257ab9c5308de0aa64ee7aceb648a7a7d987451
User & Date: jack 2025-04-22 18:35:28
Context
2025-04-22
19:14
add data generators check-in: 5c105a6ad6 user: jack tags: master, trunk
18:35
designate package and exported symbols with strings check-in: 2cefd20783 user: jack tags: master, trunk
2025-04-06
19:49
don't print the dataset in a listener demo check-in: 637a08c828 user: jack tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Code/clim-mixins.lisp.

1
2
3
4
5
6
7
8
9
10
11
;;; This file contains CLIM implementation of various utilities and mixins
;;; that may be used for interactive plots and other things.

(in-package #:eu.turtleware.polyclot.implementation)

(c:define-command-table polyclot)
(define-class <polyclot-view> (c:view) ())

;;; Color utilities.
(defvar *contrasts* (make-hash-table))
(defun contrasting-ink (n k)



|







1
2
3
4
5
6
7
8
9
10
11
;;; This file contains CLIM implementation of various utilities and mixins
;;; that may be used for interactive plots and other things.

(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

(c:define-command-table polyclot)
(define-class <polyclot-view> (c:view) ())

;;; Color utilities.
(defvar *contrasts* (make-hash-table))
(defun contrasting-ink (n k)
︙︙

Changes to Code/coordinate-system.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

(defvar +graphics-transformation+
  (c:compose-transformation-with-translation
   (c:make-scaling-transformation 1 -1) 0 1))

(defvar *unit-box*
  (c:make-rectangle* 0 0 1 1))
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

(defvar +graphics-transformation+
  (c:compose-transformation-with-translation
   (c:make-scaling-transformation 1 -1) 0 1))

(defvar *unit-box*
  (c:make-rectangle* 0 0 1 1))
︙︙

Changes to Code/dataset-and-aesthetics.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

;;; FIXME for now we hardcode column name comparisons with EQUAL.
;;; > DATASET-COLUMN-TEST, DATASET-COLUMN-KEY ?

;;; Dataset access protocol. Contains implementation for a naive data
;;; representation based on lists, where CAR and CDR are lists of headers and
;;; rows accordingly.
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

;;; FIXME for now we hardcode column name comparisons with EQUAL.
;;; > DATASET-COLUMN-TEST, DATASET-COLUMN-KEY ?

;;; Dataset access protocol. Contains implementation for a naive data
;;; representation based on lists, where CAR and CDR are lists of headers and
;;; rows accordingly.
︙︙

Changes to Code/faceting.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

;;; Faceting may encounter multiple source datasets in the single plot because a
;;; layer may have its own dataset. To avoid grouping repeatedly of the same
;;; dataset we cache results with the source dataset being the key.

(define-class <faceting> ()
  (datasets facets)
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

;;; Faceting may encounter multiple source datasets in the single plot because a
;;; layer may have its own dataset. To avoid grouping repeatedly of the same
;;; dataset we cache results with the source dataset being the key.

(define-class <faceting> ()
  (datasets facets)
︙︙

Changes to Code/layer.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

;;; In ggplot2 layers are described as a combination of the data, aesthetic
;;; mapping, a geometric object, a statistical transformation and a position
;;; adjustment. Layers are usually created with the geom constructor, so we'll
;;; just make the layer a superclass of all geometric objects (pfft).

(define-class <layer> ()
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

;;; In ggplot2 layers are described as a combination of the data, aesthetic
;;; mapping, a geometric object, a statistical transformation and a position
;;; adjustment. Layers are usually created with the geom constructor, so we'll
;;; just make the layer a superclass of all geometric objects (pfft).

(define-class <layer> ()
︙︙

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
25
26
27
28
29
30
31
32
33
34
35

36
37
(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
  (:use #:eu.turtleware.polyclot #:clim-lisp)
  (:local-nicknames (#:c #:clim)
                    (#:e #:clime)))

(defpackage #:eu.turtleware.polyclot-user
  (:use #:clim-lisp #:clim #:eu.turtleware.polyclot)
  (:local-nicknames (#:c #:clim)

                    (#:e #:clime)
                    (#:i #: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
29
30
31
32
33
34
35

(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-IDENTITY+"
           "<POSITION-JITTER>"   "+POSITION-JITTER+"
           "<POSITION-DODGE>"    "+POSITION-DODGE+"
           "<POSITION-STACK>"    "+POSITION-STACK+" 
           "<POSITION-FILL>"     "+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"
  (:use "EU.TURTLEWARE.POLYCLOT" "CLIM-LISP")
  (:local-nicknames ("C" "CLIM")
                    ("E" "CLIME")))

(defpackage "EU.TURTLEWARE.POLYCLOT-USER"
  (:use "CLIM-LISP" "CLIM" "EU.TURTLEWARE.POLYCLOT")
  (:local-nicknames ("C" "CLIM")
                    ("E" "CLIME")
                    ("I" "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")))

Changes to Code/plot.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

(define-class <polyclot> (<theme>)
  (dataset aesthetics layers scales coords faceting theme)
  (:default-initargs
   :coords (<coord-cartesian>)
   :scales (list (make-scale :continuous :x)
                 (make-scale :continuous :y))
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

(define-class <polyclot> (<theme>)
  (dataset aesthetics layers scales coords faceting theme)
  (:default-initargs
   :coords (<coord-cartesian>)
   :scales (list (make-scale :continuous :x)
                 (make-scale :continuous :y))
︙︙

Changes to Code/position-adjustment.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

(define-class <position-adjuster> () ())

;;; Aka collision modifiers.
(defgeneric adjust-data (adjustment layer dataset))

(define-class <position-identity> (<position-adjuster>) ())
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

(define-class <position-adjuster> () ())

;;; Aka collision modifiers.
(defgeneric adjust-data (adjustment layer dataset))

(define-class <position-identity> (<position-adjuster>) ())
︙︙

Changes to Code/scales-and-guides.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

;;; https://ggplot2-book.org/scales-guides.html

;;; Scales are processed in three steps:
;;;
;;; 1. for each layer scale the dataset with a transformation (i.e log)
;;; 2. after all layers are processed train scales to make them uniform
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

;;; https://ggplot2-book.org/scales-guides.html

;;; Scales are processed in three steps:
;;;
;;; 1. for each layer scale the dataset with a transformation (i.e log)
;;; 2. after all layers are processed train scales to make them uniform
︙︙

Changes to Code/statistical-transformation.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

;;; Instance of this class transform a dataset into another dataset.
(define-class <statistical-transformation> ()
  (;; Intelligent defaults (include in class definition)
   mapping)
  (:default-initargs :mapping '()))

|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

;;; Instance of this class transform a dataset into another dataset.
(define-class <statistical-transformation> ()
  (;; Intelligent defaults (include in class definition)
   mapping)
  (:default-initargs :mapping '()))

︙︙

Changes to Code/theme.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

(define-class <theme> (c:standard-bounding-rectangle)
  (title width height)
  (:default-initargs
   :title "(untitled)"
   :width 400 :height 300))

|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

(define-class <theme> (c:standard-bounding-rectangle)
  (title width height)
  (:default-initargs
   :title "(untitled)"
   :width 400 :height 300))

︙︙

Changes to Code/utilities.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot.implementation)

(defun required-argument (key)
  (error "~s is a required argument." key))

(defun required-aesthetic (key)
  (error "~s is a required aesthetic." key))

|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT.IMPLEMENTATION")

(defun required-argument (key)
  (error "~s is a required argument." key))

(defun required-aesthetic (key)
  (error "~s is a required aesthetic." key))

︙︙

Changes to Demo/cl-bench-results.lisp.

1
2
3
4
5
6
7
8
9

(in-package #:eu.turtleware.polyclot-user)

;;; Results of CL-bench are stored in files - one for each implementation -
;;; with a single form inside: (LISP-NAME . RESULTS) where RESULTS is a list
;;; of test cases in a form (TEST-NAME REAL-TIME USER-TIME SYS-TIME CONSED).
;;; If a statistic is not possible to for the implementation to produce, then
;;; it is NIL. For now we will focus on the user time.
;;;
|
<







1

2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT-USER")


;;; Results of CL-bench are stored in files - one for each implementation -
;;; with a single form inside: (LISP-NAME . RESULTS) where RESULTS is a list
;;; of test cases in a form (TEST-NAME REAL-TIME USER-TIME SYS-TIME CONSED).
;;; If a statistic is not possible to for the implementation to produce, then
;;; it is NIL. For now we will focus on the user time.
;;;
︙︙

Changes to Demo/demo.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot-user)

(defvar *demo-plots* '())

(defmacro define-demo-plot (name value &optional (description ""))
  `(progn
     (defparameter ,name ,value ,description)
     (pushnew ',name *demo-plots*)))
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT-USER")

(defvar *demo-plots* '())

(defmacro define-demo-plot (name value &optional (description ""))
  `(progn
     (defparameter ,name ,value ,description)
     (pushnew ',name *demo-plots*)))
︙︙

Changes to Demo/listener.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot-user)

(define-application-frame a-repl ()
  ()
  (:panes (int :interactor :text-style (make-text-style :fix nil nil)
                           :end-of-line-action :allow
                           :scroll-bars t)
          (dodge (make-pane 'clime:box-adjuster-gadget))
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT-USER")

(define-application-frame a-repl ()
  ()
  (:panes (int :interactor :text-style (make-text-style :fix nil nil)
                           :end-of-line-action :allow
                           :scroll-bars t)
          (dodge (make-pane 'clime:box-adjuster-gadget))
︙︙

Changes to Demo/test-data.lisp.

1
2
3
4
5
6
7
8
(in-package #:eu.turtleware.polyclot-user)

(defparameter +data/sinus+
  (loop for i from 0 upto 800 by 10
        collect (list i     (* 50 (sin (/ i 20)))) into rows
        collect (list (- i) (* 50 (sin (/ (- i) 20)))) into rows*
        finally (return (list* (list "x" "y") (append (reverse rows*) rows))))
  "Sinus on range x=[-800, 800], y=[-50, 50].")
|







1
2
3
4
5
6
7
8
(in-package "EU.TURTLEWARE.POLYCLOT-USER")

(defparameter +data/sinus+
  (loop for i from 0 upto 800 by 10
        collect (list i     (* 50 (sin (/ i 20)))) into rows
        collect (list (- i) (* 50 (sin (/ (- i) 20)))) into rows*
        finally (return (list* (list "x" "y") (append (reverse rows*) rows))))
  "Sinus on range x=[-800, 800], y=[-50, 50].")
︙︙

Changes to eu.turtleware.polyclot.asd.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
;;; ---------------------------------------------------------------------------
;;;   License: AGPL-3.0-or-later (See file 'LICENSE' for details).
;;; ---------------------------------------------------------------------------
;;;
;;;  (c) Copyright 2022 by Daniel Kochmański <daniel@turtleware.eu>
;;;
;;; ---------------------------------------------------------------------------

(in-package #:asdf-user)

(defsystem "eu.turtleware.polyclot"
  :author "Daniel Kochmański"
  :license "AGPL-3.0-or-later"
  :depends-on ("mcclim")
  :serial t
  :pathname "Code"








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
;;; ---------------------------------------------------------------------------
;;;   License: AGPL-3.0-or-later (See file 'LICENSE' for details).
;;; ---------------------------------------------------------------------------
;;;
;;;  (c) Copyright 2022 by Daniel Kochmański <daniel@turtleware.eu>
;;;
;;; ---------------------------------------------------------------------------

(in-package "ASDF-USER")

(defsystem "eu.turtleware.polyclot"
  :author "Daniel Kochmański"
  :license "AGPL-3.0-or-later"
  :depends-on ("mcclim")
  :serial t
  :pathname "Code"
︙︙