Skip to content

haavee/ppgplot

 
 

Repository files navigation

ppgplot

ppgplot - The Pythonic interface to PGPLOT, with support for both PGPLOT and Giza backends.

ppgplot is a python module (extension) providing bindings to the PGPLOT graphics library. PGPLOT is a scientific visualization (graphics) library written in Fortran by T. J. Pearson. C bindings for PGPLOT are also available. ppgplot makes the library usable by Python programs. It had support for the Numeric / numarray modules, but nowadays (>= Feb 2025) replaced by Numpy, to efficiently represent and manipulate vectors and matrices.

Installing

Option 1: Conda (Recommended)

The easiest way to install python-pgplot is via conda-forge, which automatically handles all system dependencies:

    $> conda install -c conda-forge python-pgplot
    $> python3
    >>> import ppgplot
    >>>

This method automatically installs and configures:

  • Giza graphics library
  • Cairo graphics backend
  • X11 libraries (Linux)
  • All required development headers

Option 2: PyPI

Since v1.5 (Apr 2025) the package is also available on PyPI:

    $> pip install python-pgplot
    $> python3
    >>> import ppgplot
    >>>

NOTE: Due to a package name collision, the PyPI project name is python-pgplot; the obvious package name was already claimed by something completely different

Important: PyPI installation requires system dependencies (see Requirements section below) to be manually installed first.

Option 3: From Source

It is also possible to build the package from this git-repository. You may need to create a Python venv first. See below for detailed instructions.

    $> pip install [-e] .

Note: there is a separate old-python-3.6 branch based off master, with a how-to in the commit log(s). Of course nothing works out of the box on that system - only succeeded using an (old) Anaconda3.6 base package. YMMV.

Requirements

  • Python 3.9+
  • numpy >= 1.21.0
  • PGPLOT or Giza libraries installed
  • X11 development libraries
  • pkg-config

Installing the dependencies

On Linux use your favourite package manager, e.g.:

$> sudo apt-get install giza-dev libx11-dev pkg-config

Successful installation using Homebrew on Mac OSX with:

$> brew install libx11 giza pkgconf

Installation

In principle, this extension should build out-of-the-box in a Python venv, or, if you have it, a conda virtual environment (untested at the moment). The pyproject.toml file lists all dependencies and should (...) pull them into the venv as required for building/deploying:

$> cd /path/to/checkout/of/this/repo
$> pip install [-e] .

Without -e installs the extension in the venv, with the -e keeps the module in the current directory.

Using a bespoke PGPLOT or Giza backend

The extension configuration allows compiling + linking to a locally compiled PGPLOT or Giza library.

Obviously, first install or build PGPLOT and/or Giza on your system (should you want to compare them). Then build the extension, pointing the PGPLOT_DIR environment variable to the installation directory of the backend of choice:

$> PGPLOT_DIR=/path/to/pgplot pip install [-e] . 

Notes

FORTRAN? Srsly? Actually, for plotting large numbers of points or simple, yet precise control of the graphics, the FORTRAN based PGPLOT backend is convenient and fast (a lot faster than matplotlib, and still noticeably faster than Giza). However, the upside of investing those compute cycles is that the (anti-aliased!) fonts and graphics produced by the cairo library (the actual graphics backend used by Giza) are of an amazing quality.

If ppgplot is linked against the Giza library, it can produce output in .png and .pdf, also not something to be sneezed at.

All in all, the Giza backend is an amazing job done, but it is not 100% compatible with the original PGPLOT, so it is not guaranteed your plots will come out identical.

This fork of the Python-extension owes a lot of thanks to the original author, Nick Patavalis, of ppgplot: https://github.com/npat-efault/ppgplot

About

Pythonic Interface to PGPLOT

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 87.6%
  • Python 8.2%
  • Shell 2.1%
  • Makefile 1.7%
  • Batchfile 0.4%