Getting Started
Install gleplot, make a first plot, and see which files it writes.
Installation
Requirements
Python 3.9 or later
numpy >= 1.16.0
To compile figures: GLE, with its include library (
gleinc); see GLE’s include library below
Install gleplot
Install it from GitHub:
pip install git+https://github.com/BenHuddart/gleplot.git
To work on gleplot itself, make an editable install with the development tools:
git clone https://github.com/BenHuddart/gleplot.git
cd gleplot
pip install -e ".[dev]"
Install GLE (optional but recommended)
GLE is required for direct PDF/PNG/EPS compilation. The recommended install path is the official release page:
Verify your install:
gle -finddeps
gle -info
GLE’s include library
The scripts gleplot writes include routines from GLE’s own include
library, gleinc, rather than defining them themselves. The official GLE
installers and packages ship it in the gleinc folder under the GLE_TOP
directory that gle -info prints. Check that it is there:
gle -info # note the GLE_TOP line
ls <GLE_TOP>/gleinc
A GLE built from source has no gleinc unless CMake is pointed at a
checkout of gle-library with
-DGLE_EXAMPLES_LIBRARY_PATH=/path/to/gle-library. Without rebuilding, set
the GLE_USRLIB environment variable to that checkout’s include folder.
GLE looks for an included file next to the script, then in
<GLE_TOP>/gleinc, then in GLE_USRLIB. When it finds none, savefig
raises a GLECompileError naming the missing file.
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
.glescript fileone or more external
.datfiles containing plotting data
By default, data files use a global pattern like data_0.dat, data_1.dat, etc.
To name them yourself, see data_prefix and data_name in
Configuration Guide.
The file extension picks the output. A .gle script is always written and
needs nothing else; .pdf, .png, .eps, .svg and .jpg are
compiled by GLE:
fig.savefig('plot.gle')
fig.savefig('plot.pdf')
fig.savefig('plot.png', dpi=300)
fig.savefig('plot.eps')
fig.savefig('/path/to/output/plot.pdf')
To keep each export self-contained, pass folder=True.
fig.savefig('plot.pdf', folder=True) creates a plot.gleplot directory
containing plot.pdf, the intermediate plot.gle script, and the
generated .dat files.
Next steps
The user guide covers each topic in turn, starting with Figures and Subplots and Plot Types. The Gallery shows every example with its code.