GnuplotEx.Session (gnuplot_ex v0.5.1)

Named sessions for managing multiple independent gnuplot processes.

Sessions allow you to maintain separate gnuplot contexts, useful for:

  • Running multiple plots in parallel
  • Keeping different terminal configurations
  • Isolating plot state

Example

# Start a named session
{:ok, _pid} = GnuplotEx.Session.start_link(name: :analysis)

# Plot using the session
GnuplotEx.plot(:analysis, [[:plot, 'sin(x)']])

# List active sessions
GnuplotEx.Session.list()
# => [:analysis]

# Stop session
GnuplotEx.Session.stop(:analysis)

Default Session

If you call GnuplotEx.plot/2 without a session name, it uses the one-shot port approach (no persistent session).

Summary

Functions

Returns a specification to start this module under a supervisor.

Check if a session exists.

Get session info.

List all active session names.

Execute a plot in a named session.

Start a named session.

Stop a named session.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

exists?(name)

@spec exists?(atom()) :: boolean()

Check if a session exists.

Example

GnuplotEx.Session.exists?(:analysis)
# => true

info(name)

@spec info(atom()) :: map() | nil

Get session info.

Example

GnuplotEx.Session.info(:analysis)
# => %{name: :analysis, plot_count: 5, started_at: ~U[...]}

list()

@spec list() :: [atom()]

List all active session names.

Example

GnuplotEx.Session.list()
# => [:analysis, :realtime]

plot(name, commands, datasets \\ [])

@spec plot(atom(), [list()], [list()]) :: {:ok, String.t()} | {:error, term()}

Execute a plot in a named session.

Example

GnuplotEx.Session.plot(:analysis, commands, datasets)

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Start a named session.

Options

  • :name - Session name (required)

Example

{:ok, pid} = GnuplotEx.Session.start_link(name: :my_session)

stop(name)

@spec stop(atom()) :: :ok

Stop a named session.

Example

:ok = GnuplotEx.Session.stop(:analysis)