<commit_before># plot2d
A simple 2-D plot generator for CL. 

## Overview

This project is intended to be a super easy-to-use library for
generating 2D plots. I know there are a lot of existing projects for
CL based on Gnuplot, and that's fine overall. But, I wanted something
a bit lispier - something more like the way [Racket does
it](https://docs.racket-lang.org/plot/intro.html#%28part._.Plotting_2.D_.Graphs%29).
This library based on cl-cairo2 so it produces pdf, ps, and svg
files.

## Samples

This is a work in progress, but here's the way it works so far. You
can start just by passing a function to plot:

~~~lisp
(ql:quickload :plot2d)
(use-package :plot2d)

(plot #'sin)
~~~

# !(https://raw.github.com/jlowder/plot2d/master/samples/ex1.png)

Or you can pass a list of functions to plot concurrently:

~~~lisp
(plot (list #'sin #'cos #'atan))
~~~

# !(https://raw.github.com/jlowder/plot2d/master/samples/ex2.png)

With legends, labels, and colors:

~~~lisp
(plot (list #'sin #'cos #'atan) :x-axis '(-3.14 3.14) :labels '("x-axis" "y-axis") :legend '("sine(x)" "cosine(x)" "atan(x)") :background '(1 1 1) :palette '((1 0 1) (0 1 1) (1 .5 0)))
~~~

# !(https://raw.github.com/jlowder/plot2d/master/samples/ex3.png)

More complex plots can be made by passing lists of x and y values to plot-xy:

~~~lisp
(let* ((l (loop for x from 0 to 5000 collect x))
        (theta (loop for x in l collect (* 24/5000 x pi)))
        (r (mapcar #'(lambda (x) (+ (- (expt (exp 1) (cos x)) (* 2 (cos (* 4 x)))) (expt (sin (/ x 12)) 5))) theta))
        (x (loop for a in r for b in theta collect (funcall #'(lambda (x y) (* x (cos (+ y (/ pi 2))))) a b)))
        (y (loop for a in r for b in theta collect (funcall #'(lambda (x y) (* x (sin (+ y (/ pi 2))))) a b))))
   (plot-xy x y :background '(1 1 1) :palette (list '(0 0 1)) :legend '("<NAME> Butterfly")))
~~~

# !(https://raw.github.com/jlowder/plot2d/master/samples/ex4.png)<commit_msg>another attempt<commit_after># plot2d
A simple 2-D plot generator for CL. 

## Overview

This project is intended to be a super easy-to-use library for
generating 2D plots. I know there are a lot of existing projects for
CL based on Gnuplot, and that's fine overall. But, I wanted something
a bit lispier - something more like the way [Racket does
it](https://docs.racket-lang.org/plot/intro.html#%28part._.Plotting_2.D_.Graphs%29).
This library based on cl-cairo2 so it produces pdf, ps, and svg
files.

## Samples

This is a work in progress, but here's the way it works so far. You
can start just by passing a function to plot:

~~~lisp
(ql:quickload :plot2d)
(use-package :plot2d)

(plot #'sin)
~~~

# ![ex1](https://raw.github.com/jlowder/plot2d/master/samples/ex1.png)

Or you can pass a list of functions to plot concurrently:

~~~lisp
(plot (list #'sin #'cos #'atan))
~~~

# ![ex2](https://raw.github.com/jlowder/plot2d/master/samples/ex2.png)

With legends, labels, and colors:

~~~lisp
(plot (list #'sin #'cos #'atan) :x-axis '(-3.14 3.14) :labels '("x-axis" "y-axis") :legend '("sine(x)" "cosine(x)" "atan(x)") :background '(1 1 1) :palette '((1 0 1) (0 1 1) (1 .5 0)))
~~~

# ![ex3](https://raw.github.com/jlowder/plot2d/master/samples/ex3.png)

More complex plots can be made by passing lists of x and y values to plot-xy:

~~~lisp
(let* ((l (loop for x from 0 to 5000 collect x))
        (theta (loop for x in l collect (* 24/5000 x pi)))
        (r (mapcar #'(lambda (x) (+ (- (expt (exp 1) (cos x)) (* 2 (cos (* 4 x)))) (expt (sin (/ x 12)) 5))) theta))
        (x (loop for a in r for b in theta collect (funcall #'(lambda (x y) (* x (cos (+ y (/ pi 2))))) a b)))
        (y (loop for a in r for b in theta collect (funcall #'(lambda (x y) (* x (sin (+ y (/ pi 2))))) a b))))
   (plot-xy x y :background '(1 1 1) :palette (list '(0 0 1)) :legend '("<NAME> Butterfly")))
~~~

# ![ex4](https://raw.github.com/jlowder/plot2d/master/samples/ex4.png)
{'fraction_non_alphanumeric': 0.17580727831881088, 'fraction_numerical': 0.032803690415171706, 'mean_word_length': 3.570257611241218, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1808275', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1438, 'n_words': 548}