Metadata-Version: 2.4
Name: gleplot
Version: 6.1.0
Summary: Write standard GLE (Graphics Layout Engine) from Python, with matplotlib-shaped names
Author: gleplot contributors
License: GPL-2.0+
Project-URL: Homepage, https://github.com/benhuddart/gleplot
Project-URL: Documentation, https://benhuddart.github.io/gleplot
Project-URL: Repository, https://github.com/benhuddart/gleplot
Project-URL: Bug Tracker, https://github.com/benhuddart/gleplot/issues
Keywords: plotting,graphics,GLE,scientific-visualization,publication-quality
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.16.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov>=2.0; extra == "dev"
Requires-Dist: black<27,>=26; python_version >= "3.10" and extra == "dev"
Requires-Dist: isort>=5.12; extra == "dev"
Requires-Dist: flake8>=6.0; extra == "dev"
Requires-Dist: mypy<3,>=2.3; python_version >= "3.10" and extra == "dev"
Requires-Dist: python-semantic-release>=10; extra == "dev"
Requires-Dist: Pillow>=9.1; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=4.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
Requires-Dist: myst-parser>=0.18; extra == "docs"
Requires-Dist: Pillow>=9.1; extra == "docs"
Provides-Extra: gle
Dynamic: license-file

# gleplot

[![Tests](https://github.com/BenHuddart/gleplot/actions/workflows/test.yml/badge.svg)](https://github.com/BenHuddart/gleplot/actions/workflows/test.yml)
[![Docs](https://github.com/BenHuddart/gleplot/actions/workflows/publish_docs.yml/badge.svg)](https://benhuddart.github.io/gleplot/)
[![License: GPL-2.0-or-later](https://img.shields.io/badge/license-GPL--2.0--or--later-blue.svg)](https://github.com/BenHuddart/gleplot/blob/main/LICENSE)

**gleplot** writes standard [GLE](https://glx.sourceforge.io/) (Graphics Layout Engine) scripts from Python, through matplotlib's names where they map cleanly. GLE compiles the script to publication-quality PDF, EPS, SVG, PNG or JPG.

<img src="https://benhuddart.github.io/gleplot/_static/gallery/example_combined_errorbars.webp" alt="Measured points with horizontal and vertical error bars, and a dashed y = x² curve through them" width="560">

The code that draws it (the gallery's [Combined X+Y Error Bars](https://benhuddart.github.io/gleplot/gallery.html#combined-x-y-error-bars) example):

```python
import numpy as np
import gleplot as glp

x = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
y = np.array([1.8, 4.2, 9.1, 16.3, 24.8])
xerr = np.array([0.15, 0.20, 0.10, 0.25, 0.18])
yerr = np.array([0.3, 0.5, 0.6, 0.8, 1.0])

fig = glp.figure(figsize=(8, 6))
ax = fig.add_subplot(111)
ax.errorbar(x, y, yerr=yerr, xerr=xerr, fmt="o", color="blue", capsize=4,
            label="Measured")
x_fit = np.linspace(0.5, 5.5, 100)
ax.plot(x_fit, x_fit**2, color="red", linestyle="--", label="y = x²")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_title("Combined X and Y Error Bars")
ax.legend()

fig.savefig("fit.gle")  # the GLE script and its data files; GLE not needed
fig.savefig("fit.pdf")  # compiled by GLE
```

## Why gleplot

- **The output is a script you can read and edit.** `fit.gle` is a short plain-text GLE file, with the data in `.dat` files beside it. Change a label or a colour by hand, and GLE compiles it to vector PDF, EPS or SVG, or to PNG or JPG.
- **Scripts open again.** `glp.open_gle("fit.gle")` reads a `.gle` file back into a `Figure` you can change from Python and save.
- **Unrecognised GLE is kept.** When you open a hand-written file, GLE that gleplot does not model is written back in place on save rather than dropped, and each place it had to keep raw GLE or guess is recorded as a note ([opening GLE files](https://benhuddart.github.io/gleplot/guides/OPENING_GLE_FILES.html)).
- **GLE is optional for writing.** Saving `.gle` works without GLE installed; you need GLE only to compile.

## Install

gleplot needs Python 3.9 or later and numpy. Install it from PyPI:

```bash
pip install gleplot
```

For the latest development version, install from GitHub with `pip install git+https://github.com/BenHuddart/gleplot.git`.

To compile figures, install **GLE 4.3+** from the [GLE releases](https://github.com/vlabella/GLE/releases/latest) and check it with `gle -info`. GLE's include library (`gleinc`) is required too; the release packages ship it, and [GLE's include library](https://benhuddart.github.io/gleplot/getting_started.html#gle-s-include-library) covers a GLE built from source. The [getting started guide](https://benhuddart.github.io/gleplot/getting_started.html) covers Ghostscript, LaTeX and `gle -finddeps`.

To work on gleplot itself, use an editable install with the development tools, as described in [CONTRIBUTING.md](https://github.com/BenHuddart/gleplot/blob/main/CONTRIBUTING.md):

```bash
git clone https://github.com/BenHuddart/gleplot.git
cd gleplot
pip install -e ".[dev]"
```

## What it can plot

- Lines, scatter, bars, steps, stems and histograms ([plot types](https://benhuddart.github.io/gleplot/guides/PLOT_TYPES.html))
- [Error bars](https://benhuddart.github.io/gleplot/gallery.html#combined-x-y-error-bars), symmetric or asymmetric, in x and y
- [Fills between curves](https://benhuddart.github.io/gleplot/gallery.html#fill-between)
- [Heatmaps](https://benhuddart.github.io/gleplot/gallery.html#heatmap-imshow) and [contours](https://benhuddart.github.io/gleplot/gallery.html#phase-diagram-tripcolor-tricontour) with colour bars
- [Subplots](https://benhuddart.github.io/gleplot/gallery.html#x2-subplot-grid) and [shared axes](https://benhuddart.github.io/gleplot/gallery.html#shared-x-axis-stacked)
- [Log scales](https://benhuddart.github.io/gleplot/gallery.html#log-scale), [secondary axes](https://benhuddart.github.io/gleplot/gallery.html#secondary-y-axis) and [polar plots](https://benhuddart.github.io/gleplot/gallery.html#polar-plot)
- [Reference lines and shaded spans](https://benhuddart.github.io/gleplot/guides/REFERENCE_LINES_AND_SPANS.html), [text and arrows](https://benhuddart.github.io/gleplot/gallery.html#text-annotations)
- [Series read from existing data files](https://benhuddart.github.io/gleplot/guides/FILE_BASED_SERIES.html)

The [gallery](https://benhuddart.github.io/gleplot/gallery.html) shows every example with its code.

## Coming from matplotlib

`figure`, `subplots`, `plot`, `scatter`, `errorbar`, `savefig` and the other matplotlib names take matplotlib's arguments. Where GLE cannot do what a keyword asks, gleplot accepts it and warns; the [matplotlib migration guide](https://benhuddart.github.io/gleplot/guides/MATPLOTLIB_MIGRATION.html) lists each difference. gleplot does not emulate what GLE cannot draw, so there is no pie chart, box plot or broken axis.

## Upgrading from gleplot 5

gleplot 6 removes those features, raises on a bad argument when the call is made, and draws with matplotlib's colour cycle and bars without an outline. [Migrating from gleplot 5 to 6](https://benhuddart.github.io/gleplot/guides/MIGRATING_TO_6.html) lists each change and what to use instead.

## Documentation

The [documentation site](https://benhuddart.github.io/gleplot/) has the user guides and the API reference.

## Contributing

See [CONTRIBUTING.md](https://github.com/BenHuddart/gleplot/blob/main/CONTRIBUTING.md). Questions and feature requests go to [GitHub issues](https://github.com/BenHuddart/gleplot/issues).

## License

gleplot is licensed under the [GPL-2.0 or later](https://github.com/BenHuddart/gleplot/blob/main/LICENSE).
