plottah

An Erlang/LFE gnuplot process server


License
Apache-2.0

Documentation

plottah

Build Status LFE Versions Erlang Versions Tags

Project Logo

An Erlang/LFE gnuplot process server

Table of Contents

About ↟

This library aims to provide a means for programmers of the BEAM VM to use gnuplot in their native language. To accomplish this, it runs gnuplot in shell mode in a managed OS process. The erlexec library is used for two-way communications (via stdin and combined stdout/stderr).

This library is in the early stages of development, so to-date only a few functions are provided in the API. See the "Usage" section below for example usage (also the ./examples directory). For now, the API is a very thin layer over the gnuplot shell, but in the future a DSL may be provided for a more functional programming language experience.

Build ↟

This project depends upon:

  • Erlang 21+
  • rebar3
  • gnuplot being installed on the system

Note that development was done against the gnuplot installed by Homebrew on macos.

With the dependencies in place, the library may be compiled with the following:

rebar3 compile

REPL ↟

To start an interactive session in the LFE REPL:

make repl

and then:

(plottah:start)

This runs the gnuplot shell in an OS process and allows for two-way communication. See below on how to communicate with the process.

Tests ↟

rebar3 as test check

Examples ↟

Show the list of examples:

rebar3 as examples list

Run a specific example:

rebar3 as examples lfe run -- 3d-hidden

Usage ↟

First, be sure you've compiled the project using the instructions above!

Then start the REPL (see above), including starting up plottah. You can then run code like the following in the REPL (example taken from here):

(defun options ()
 #m(title "Hidden line removal of explicit surfaces"
    style "increment default"
    view "70, 45, 1, 1"
    samples "20, 20"
    isosamples "20, 20"
    hidden3d "back offset 1 trianglepattern 3 undefined 1 altdiagonal bentover"
    style "data lines"
    xrange "[ -3.00000 : 3.00000 ] noreverse nowriteback"
    x2range "[ * : * ] noreverse writeback"
    yrange "[ -3.00000 : 3.00000 ] noreverse nowriteback"
    y2range "[ * : * ] noreverse writeback"
    zrange "[ * : * ] noreverse writeback"
    cbrange "[ * : * ] noreverse writeback"
    rrange "[ * : * ] noreverse writeback"))

(defun eqn ()
  "sin(x*x + y*y) / (x*x + y*y)")

(plottah:splot (eqn) (options))

With that last, a window should pop up showing the following:

3D graph screenshot

License ↟

Apache License, Version 2.0

Copyright © 2023, Duncan McGreggor oubiwann@gmail.com.