Getting Started

This guide is designed as a short, practical path:

  1. Install dependencies

  2. Generate your first plot

  3. Learn how output files are created

  4. Use shared axes and custom data file names

Installation

Requirements

  • Python 3.7 or later

  • numpy >= 1.16.0

Install gleplot

From source (recommended for development):

git clone https://github.com/BenHuddart/gleplot.git
cd gleplot
pip install -e .

With development dependencies:

pip install -e ".[dev]"

Prefer a GUI? Try the desktop editor

If you’d rather build figures interactively than write Python, gleplot ships a PySide6 desktop editor with a live preview. Download a prebuilt Windows or macOS app from the GitHub Releases page, or install it into a Python environment and launch it:

pip install "gleplot[gui]"
gleplot-gui

The editor uses the same GLE install described above for its live preview and compiled export. See GUI Editor for the full walkthrough.

First Plot (Step by Step)

import numpy as np
import gleplot as glp

# 1) Create data
x = np.linspace(0, 10, 100)
y = np.sin(x)

# 2) Create figure and axis
fig = glp.figure(figsize=(8, 6))
ax = fig.add_subplot(111)

# 3) Plot and label
ax.plot(x, y, label='sin(x)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_title('My first gleplot figure')
ax.legend()

# 4) Save
fig.savefig('first_plot.gle')  # Always works (script + data files)
fig.savefig('first_plot.pdf')  # Requires GLE installed

How Output Files Work

When you call savefig, gleplot writes:

  • a main .gle script file

  • one or more external .dat files containing plotting data

By default, data files use a global pattern like data_0.dat, data_1.dat, etc.

If you want to keep each export self-contained, pass folder=True to savefig. For example, fig.savefig('first_plot.pdf', folder=True) creates a first_plot.gleplot directory containing the compiled output, the intermediate .gle script, and the generated .dat files.

New: Custom Data File Names

Use data_prefix when creating a figure (or via subplots) to control the data-file naming scheme.

import numpy as np
import gleplot as glp

x = np.linspace(0, 1, 20)
y = x**2

fig = glp.figure(data_prefix='experimentA')
ax = fig.add_subplot(111)
ax.plot(x, y)
fig.savefig('experimentA_plot.gle')

This produces files such as:

  • experimentA_plot.gle

  • experimentA_0.dat

The prefix is used verbatim (note the preserved capital A), so it must be usable as a GLE data filename. Whitespace, control characters, !, ", + and the path separators / and \ raise ValueError when the figure is created, rather than producing a script that fails to compile. See docs/guides/CONFIGURATION.md for the full list.

New: Shared Axes in Subplots

For aligned multi-panel figures, share the x-axis or y-axis across subplots.

import numpy as np
import gleplot as glp

x = np.linspace(0, 10, 200)
fig, axes = glp.subplots(3, 1, sharex=True, figsize=(8, 10))

axes[0].plot(x, np.sin(x))
axes[1].plot(x, np.cos(x))
axes[2].plot(x, np.sin(x) + np.cos(x))
axes[2].set_xlabel('time')

fig.savefig('shared_x_example.gle')

With sharex=True, only the bottom row shows x tick labels and x-axis label. With sharey=True, only the leftmost column shows y tick labels and y-axis label.