Skip to content

Lisp-Stat/quick-plot

Repository files navigation

Contributors Forks Stargazers Issues MS-PL License LinkedIn


Logo

Quick Plot for Common Lisp

Composable, ggplot-style plotting helpers for Lisp-Stat
Explore the docs »

Report Bug · Request Feature · Reference Manual

Table of Contents

  1. About the Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Resources
  6. Contributing
  7. License
  8. Contact

About the Project

Quick Plot provides composable helper functions for building Vega-Lite plot specifications in Common Lisp. Inspired by R's ggplot2, plots are constructed by combining independent layers — geometry, labels, scales, coordinates and themes — rather than writing monolithic JSON-like plists by hand.

The system is organized into three packages. The geom package provides mark types (point, bar, histogram, box-plot, line), each responsible for encoding data fields into a single visual form. The gg package provides layering modifiers (label, axes, coord, theme, tooltip) that control everything around the marks. The qplot package provides a single qplot function that collapses plot definition, registration and rendering into one call for interactive REPL use.

Every helper returns a plist fragment. A recursive merge-plists combines them into a single Vega-Lite spec. A mark function never sets axis titles; label never touches encodings; theme never alters mark types. This separation means any helper can be used with any plot type, and layers can be added, removed or swapped without affecting the rest of the specification.

Built With

Getting Started

To get a local copy up and running follow these steps:

Prerequisites

An ANSI Common Lisp implementation. Developed and tested with SBCL.

Installation

Getting the source

To make the system accessible to ASDF (a build facility, similar to make in the C world), clone the repository in a directory ASDF knows about. By default the common-lisp directory in your home directory is known. Create this if it doesn't already exist and then:

  1. Clone the repositories
cd ~/common-lisp && \
git clone https://github.com/Lisp-Stat/quick-plot
  1. Reset the ASDF source-registry to find the new system (from the REPL)
    (asdf:clear-source-registry)
  2. Load the system
    (asdf:load-system :quick-plot)

If you have installed the slime ASDF extensions, you can invoke this with a comma (',') from the slime REPL.

Getting dependencies

To get the third party systems that quick-plot depends on, you can use a dependency manager, such as Quicklisp or CLPM. Once installed, get the dependencies with either of:

(clpm-client:sync :sources "quick-plot") ;sources may vary
(ql:quickload :quick-plot)

You need do this only once. After obtaining the dependencies, you can load the system with ASDF as described above without first syncing sources.

Usage

Import the helper functions and load the Vega example datasets:

(vega:load-vega-examples)

(import '(geom:point geom:bar geom:histogram geom:box-plot geom:line))
(import '(gg:label gg:axes gg:coord gg:theme gg:tooltip))
(import '(qplot:qplot))

Create a scatter plot with color encoding and axis labels:

(qplot 'cars vgcars
  `(:title "Horsepower vs. Fuel Efficiency")
   (point :horsepower :miles-per-gallon
          :color :origin :filled t)
   (label :x "Horsepower" :y "Miles per Gallon"))

Create a histogram of a quantitative variable:

(qplot 'mpg-dist vgcars
  `(:title "Distribution of Miles per Gallon")
   (histogram :miles-per-gallon :color "darkslategray")
   (label :x "Miles per Gallon" :y "Count"))

Create a bar chart with aggregation:

(qplot 'avg-mpg vgcars
  `(:title "Average MPG by Origin")
   (bar :origin :miles-per-gallon :aggregate :mean)
   (label :x "Origin" :y "Mean MPG"))

For more examples, please refer to the Documentation.

Roadmap

See the open issues for a list of proposed features (and known issues).

Resources

This system is part of the Lisp-Stat project; that should be your first stop for information. Also see the resources and community page for more information.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. Please see CONTRIBUTING for details on the code of conduct, and the process for submitting pull requests.

License

Distributed under the MS-PL License. See LICENSE for more information.

Contact

Project Link: https://github.com/lisp-stat/quick-plot

About

ggplot-Style Plotting for Lisp-Stat

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors