View Source Gnuplot (gnuplot v1.22.270)

Interface to the Gnuplot graphing library.

Plot a sine function where Gnuplot generates the samples:

Gnuplot.plot([
  ~w(set autoscale)a,
  ~w(set samples 800)a,
  [:plot, -30..20, 'sin(x*20)*atan(x)']
])

Plot a sine function where your program generates the data:

Gnuplot.plot([
    [:plot, "-", :with, :lines :title, "sin(x*20)*atan(x)"]
  ],
  [
    for x <- -30_000..20_000, do: [x / 1000.0 , :math.sin(x * 20 / 1000.0) * :math.atan(x / 1000.0) ]
  ]
)

Link to this section Summary

Functions

Build a comma separated list from a list of terms.

Build a comma separated list of two terms.

Build a comma separated list of three terms.

Build a comma separated list of four terms.

Build a comma separated list of five terms.

Build a comma separated list of six terms.

Transmit commands without dataset.

Transmit commands and datasets to Gnuplot.

Builds a comma separated list of plot commands that are overlayed in a single plot.

Build a comma separated list of two or more overlayed 3D plots (as 2D projections).

Link to this section Types

@type command() :: [command_term(), ...]
@type command_term() :: atom() | charlist() | number() | Range.t() | String.t()

Link to this section Functions

Build a comma separated list from a list of terms.

Build a comma separated list of two terms.

Build a comma separated list of three terms.

Build a comma separated list of four terms.

Build a comma separated list of five terms.

Build a comma separated list of six terms.

@spec plot([command()]) ::
  {:ok, String.t()} | {:error, String.t(), [String.t()]} | :timeout

Transmit commands without dataset.

Link to this function

plot(commands, datasets)

View Source
@spec plot([command()], [Dataset.t()]) ::
  {:ok, String.t()} | {:error, String.t(), [String.t()]} | :timeout

Transmit commands and datasets to Gnuplot.

examples

Examples

iex> Gnuplot.plot([[:plot, "-", :with, :lines]], [[[0, 0], [1, 2], [2, 4]]])
{:ok, "plot "-" with lines"}
@spec plots([command()]) :: list()

Builds a comma separated list of plot commands that are overlayed in a single plot.

Only useful inside plot/1:

import Gnuplot

plot([
  [:set, :title, "Sine vs Cosine"],
  plots([
    ['sin(x)'],
    ['cos(x)']
  ])
])

is equivalent to:

set title "Sine vs Cosine"
plot sin(x),cos(x)
@spec splots([command()]) :: list()

Build a comma separated list of two or more overlayed 3D plots (as 2D projections).

Only useful inside plot/1:

import Gnuplot

plot([
  [:set, :grid],
  splots([
    ['x**2+y**2'],
    ['x**2-y**2']
  ])
])