GithubHelp home page GithubHelp logo

lisp-stat / plot Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 10.0 532 KB

A vega-lite DSL for Common Lisp

Home Page: https://lisp-stat.github.io/plot/

License: Microsoft Public License

Common Lisp 100.00%
common-lisp plotting vega-lite

plot's Introduction

Contributors Forks Stargazers Issues MS-PL License LinkedIn


Logo

Plot

A library for plotting with Common Lisp
Explore the tutorial »

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

The Plot system provides a way to visualise data. It includes functions for text-based plotting that work in the REPL, and JavaScript visualisations that are rendered in a browser. It is designed as a front end 'grammar', modeled after that Grammar of Graphics and implemented with various back ends. Currently Vega-Lite is complete as a backend. It is integrated with data-frame, and can also be used independently.

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 and CCL.

Installation

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/plot
  1. From the REPL reset the ASDF source-registry to find the new systems:
    (asdf:clear-source-registry)
  2. Load the system
    (asdf:load-system :plot/vega)

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 these system may depend on you can use a dependency manager, such as Quicklisp or CLPM Once installed, get the dependencies with either of:

(clpm-client:sync :sources "clpi") ;sources may vary
(ql:quickload :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

For 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 pages 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/plot

plot's People

Contributors

braised-babbage avatar jg20019 avatar jkordani avatar snunez1 avatar symbolics avatar tobyworland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

plot's Issues

Cannot open browser on Windows

Following "Getting started" I get the below error. Looks like the Chrome path is invalid. On Windows 11 Chrome is installed in Program Files, not Program Files (x86)\\ and the path should not contain double \.


* (plot:plot-from-file (vglt:save-plot 'cars-plot))

debugger invoked on a SIMPLE-ERROR in thread #<THREAD "main thread" RUNNING {10010B0523}>: Couldn't execute "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe": The system cannot find the file specified.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-EXT:RUN-PROGRAM "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" ("--user-data-dir=C:/Users/marti/AppData/Local/Temp/plot/chrome-data-G784" "--window-size=800,600" "--app=file:///C:/Users/marti/AppData/Local/Temp/plot/cars-plot.html") :ENV NIL :ENVIRONMENT NIL :WAIT NIL :SEARCH T :INPUT NIL :IF-INPUT-DOES-NOT-EXIST :ERROR :OUTPUT NIL :IF-OUTPUT-EXISTS :APPEND :ERROR NIL :IF-ERROR-EXISTS :APPEND :STATUS-HOOK NIL :EXTERNAL-FORMAT :UTF-8 :DIRECTORY NIL :ESCAPE-ARGUMENTS T)
0]

Loading plot/vega starts chrome browser

Just loading the system via ASDF causes the chrome browser to be displayed. It appears to be caused by the executable-present-p function? I assume this behaviour is not intentional?

Some systems failed to build for Quicklisp dist

Building with SBCL 2.2.1.147-31b6a20e3 / ASDF 3.3.5 for quicklisp dist creation.

Trying to build commit id 8eb57ee

plot fails to build with the following error:

; caught ERROR:
;   READ error during COMPILE-FILE: Package CL-PPCRE does not exist. Line: 11, Column: 21, File-Position: 651 Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /home/quicklisp/quicklisp-controller/dist/build-cache/plot/6c02f955806d7a63e0d013d91e08029c683d6077/plot-20220306-git/plot.lisp" {1006416BE3}>
...
Unhandled UIOP/LISP-BUILD:COMPILE-FILE-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING {1001BD0003}>: COMPILE-FILE-ERROR while compiling #<CL-SOURCE-FILE "plot" "plot">

plot/vglt fails to build because of a failure in plot.

Full log here

Implement split stems in stemplots

When there are a large number of observations, it can be helpful to split the stems in a stem-and-leaf plot so that one has leaves 0-4 and another 5-9. The stem-size argument could be used to implement this without too much difficulty by keeping track of the 'base' stem and adjusting the print. E.g. use a stem-size of 5, but print each stem twice and adjust the leaf size (currently hard-coded to 1).

Vlime Swank crash when loading :plot/vega

Hello, I am pretty new to Lisp, and currently I'm using Neovim with Vlime and Roswell with SBCL 2.3.9 as a development environment.
When I try loading plot/vega package using (ql:quickload :plot/vega), I get the following error in the Vlime server output window:

  <INFO> [02:05:22] vlime-usocket - Control thread stopping: (:SWANK-DATA-ERROR "No policy for symbols as keys defined. Please check YASON:*SYMBOL-KEY-ENCODER*.")
;; swank:close-connection: end of file on #<SB-SYS:FD-STREAM for "socket 127.0.0.1:35825, peer: 127.0.0.1:41070" {1003696823}>

Running ros run --eval '(ql:quickload :plot/vega)' loads the package successfully.
I also had no problem a while ago using vim-slime (which I think just sends expression text to an independent REPL in another Vim or Tmux window), so to me it seems like a Vlime- or Swank-specific issue.
Could you please give me some advice on how to debug this further?

SEQ-MAX is undefined.

I am getting the following when running stem-and-leaf functions.

UNDEFINED-FUNCTION: The function PLOT/TEXT::SEQ-MAX is undefined.

I am running on an apple MacBook Pro M2.

Getting Started plot error

Hello,
I just discovered this awesome package and ran into a small issue when going through the Getting Started.

This is was I have evaluated in sbcl:

(ql:quickload :lisp-stat)
;; for plotting
(ql:quickload :plot/vega)

(in-package :ls-user)

(data :vgcars)

(plot:plot
 (vega:defplot hp-mpg
   `(:title "Horsepower vs. MPG"
     :description "Horsepower vs miles per gallon for various cars"
     :data ,vgcars
     :mark :point
     :encoding (:x (:field :horsepower :type :quantitative)
                :y (:field :miles-per-gallon :type :quantitative)))))

Everything evaluates without errors, except for the last part with PLOT, which returns this error:

The value
  nil
is not of type
  (or string pathname synonym-stream file-stream)
when binding pathname
   [Condition of type type-error]

Restarts:
 0: [retry] Retry SLIME interactive evaluation request.
 1: [*abort] Return to SLIME's top level.
 2: [abort] abort thread (#<thread "worker" running {103A24C633}>)

Backtrace:
  0: (sb-ext:native-namestring nil) [external]
  1: (sb-ext:run-program nil ("--user-data-dir=/tmp/plot/chrome-data" "--no-default-browser-check=1" "--no-first-run=1" "--window-size=800,600" "--app=file:///tmp/plot/hp-mpg.html") :env nil :environment n..
  2: (uiop/launch-program:launch-program (nil "--user-data-dir=/tmp/plot/chrome-data" "--no-default-browser-check=1" "--no-first-run=1" "--window-size=800,600" "--app=file:///tmp/plot/hp-mpg.html") :ignore..
  3: (sb-int:simple-eval-in-lexenv (plot:plot (vega:defplot hp-mpg (sb-int:quasiquote #))) #<NULL-LEXENV>)
  4: (eval (plot:plot (vega:defplot hp-mpg (sb-int:quasiquote #))))
  5: ((lambda nil :in swank:interactive-eval))
 --more--

I did follow the backtrace to discover the graph I wanted was in /tmp/plot/ and I just needed to load it manually into firefox to view. What is this error though? I assume firefox should automagically open the graph for me.

I am running sbcl 2.2.11-1 on Artix Linux s6. I also am using ultralisp, as according to Lisp-Stat/lisp-stat#13 it can help.

IMDB example requires cl-date-time-parser

However this slightly abuses ASDF / require functionality, and there's no guarantee that the system exists on the users machine. Probably imdb.lisp should have some ASDF magic instead of require.

error reading gapminder.lisp

After some time trying to deal with the various unreleased dependencies of plot, I was able to get things mostly loading. However, I know get the following error:

end of file on #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}>
   [Condition of type END-OF-FILE]

Restarts:
 0: [RETRY] Retry EVAL of current toplevel form.
 1: [CONTINUE] Ignore error and continue loading file ".../quicklisp/local-projects/lisp-stat/data/gapminder.lisp".
 2: [ABORT] Abort loading file "/Users/CHarmon/quicklisp/local-projects/lisp-stat/data/gapminder.lisp".
 3: [RETRY] Retry SLIME REPL evaluation request.
 4: [*ABORT] Return to SLIME's top level.
 5: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {700368E1F3}>)

Backtrace:
  0: (PEEK-CHAR NIL #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}> T NIL #<unused argument>)
  1: (YASON::PARSE-OBJECT #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}>)
  2: ((:METHOD YASON::PARSE% (STREAM)) #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}>) [fast-method]
  3: (YASON:PARSE #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}> :OBJECT-KEY-FN NIL :OBJECT-AS NIL :JSON-ARRAYS-AS-VECTORS NIL :JSON-BOOLEANS-AS-SYMBOLS NIL :JSON-NULLS-AS-KEYWORD NIL)
  4: (YASON::%PARSE-ARRAY #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}> #<FUNCTION (LAMBDA (YASON::ELEMENT) :IN YASON::PARSE-ARRAY) {703411EC9B}>)
  5: (YASON::PARSE-ARRAY #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}>)
  6: ((:METHOD YASON::PARSE% (STREAM)) #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}>) [fast-method]
  7: (YASON:PARSE #<DEXADOR.DECODING-STREAM:DECODING-STREAM {703411EB93}> :OBJECT-KEY-FN NIL :OBJECT-AS NIL :JSON-ARRAYS-AS-VECTORS NIL :JSON-BOOLEANS-AS-SYMBOLS NIL :JSON-NULLS-AS-KEYWORD NIL)
  8: (VEGA::JSON-TO-DATA-COLUMNS "http://raw.githubusercontent.com/vega/vega-datasets/master/data/gapminder.json" :MAP-ALIST (("" . :NA) ("NIL" . :NA)))
  9: (VEGA:READ-VEGA "http://raw.githubusercontent.com/vega/vega-datasets/master/data/gapminder.json" :MAP-ALIST (("" . :NA) ("NIL" . :NA)))

Is this a bona fide fproblem with the json file or do I just have the-latest-from-quicklisp-but-not-really-new-enough yason?

thanks!

plot/vglt can't be found

Trying to install, I cloned the package into "~/quicklisp/local-projects" and ran (ql:quicklisp :plot) and that seems to load fine, though (plot:plot ...) returns error:

The function PLOT:PLOT is undefined.
[Condition of type UNDEFINED-FUNCTION]

If I run (asdf:clear-source-registry), and (ql:quicklisp :plot/vglt) I get an error:

Component :PLOT/VGLT not found
[Condition of type ASDF/FIND-COMPONENT:MISSING-COMPONENT]

I've run and currently run many projects out of ~/quicklisp/local-projects/ just fine...

I imagine this is something simple I seem to be missing, but if it has happened to others, a fix can be stored here.

Implement back-to-back stemplot

The code for a single stemplot should point the way. I would start by modifying the code to write the leaves for each stem into a single string (one string for each set of leaves, i.e. two leaf strings per stem, one for each side), and then determining the length of the largest on the left-hand side. This will give you the padding (mincol) to use in format. Once the padding is known, loop through the stems and:

  1. Print left side leaf string, right padded to the largest string
  2. Print the stem
  3. Print the right-side leaf string

is there a way to not launch a new browser process for each new graph?

Using plot (which defaults to chrome, and I can't seem to make firefox work, but that's another problem), every time I create a plot, it launches a new Chrome process. This wouldn't be so horrible if Chrome didn't think it was a brand new install every time it launches, asking me if I want Chrome to be my default browser and if I want to send data to google, neither of which I want. Any way to make the default be opening a new window in, say, firefox? Or, at a minimum, using an existing chrome process?

camelCase axis params problem

Hello, I have a problem with the axis parameters.
"x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0, "titleFontSize": 20, "labelFontSize":20}},

labelAngle, titleFontSize, labelFontSize are camelCase, but when I use them from

(write-vega-spec (vega:defplot simple-line-plot .... :encoding (:x (:field ,(assoc-path html '("eje-x")) type ,(assoc-path html '("eje-x-type")) :axis (:labelAngle 0 :titleFontSize 20 :labelFontSize 20))

They are all lowercase and it doesn't work
output
"x": { "field": "fecha", "type": "temporal", "axis": {"labelangle": 0, "titlefontsize": 20, "labelfontsize": 20} },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.