Skip to main content

Fiject

Object-oriented, two-stage PDF figure generators in Python.

Gives an answer to "How can I change the look of a figure without re-computing its data?" which isn't possible in matplotlib nor seaborn.

pip install fiject

Features

  • Two-stage figure generation:
    • Addition stage: Incrementally add data to figure objects, rather than needing to do it all at once along with visual parameters. Data caching allows skipping this step when a figure needs to be reformatted but not recomputed.
    • Commit stage: Format the data stored in a figure object, with a simple interface that hides the complexities of matplotlib and seaborn.
  • Supported figure types:
    • LineGraph: points connected by lines.
    • Bars: bar plot on a categorical axis.
    • MultiHistogram: one or more histograms on the same numerical axis. Can also be committed to box plots.
    • ScatterPlot: unconnected points.
    • Table: LaTeX tables with hierarchical rows and hierarchical columns, column stylisation (e.g. rounding, min/max bolding, ...) and borders where you need them.

Example

Let's say you have a machine learning project where a classifier called model is trained and then evaluated on precision (Pr), recall (Re) and F1 score, for 5 different values of a hyperparameter h. You would do your experiments as follows:

from fiject import LineGraph, CacheMode

g = LineGraph("project-results", caching=CacheMode.IF_MISSING)
if g.needs_computation:
    h_values = [0.1, 0.25, 0.5, 0.7, 1.0]
    for h in h_values:
        # ...
        # model.trainModel(h)  # Takes hours to compute. We don't want to repeat it just to reformat the graph!
        # pr, re, f1 = model.evaluateYourModel()
        # ...
        g.add("Pr",    h, pr)
        g.add("Re",    h, re)
        g.add("$F_1$", h, f1)
              
g.commit(aspect_ratio=(4,3), y_lims=(0, 100), x_tickspacing=0.1, y_tickspacing=10,
         x_label="Hyperparameter value", y_label="Binary classification performance [\\%]")

A PDF project-results_0.pdf will appear, and the data will be cached in a file project-results_0.json.

Notice that the CacheMode along with the check if g.needs_computation will ensure that you don't have to redo your computation if you don't like the way your figure came out the first time. You can just change the parameters to g.commit() and re-run the same code to get a new PDF project-results_1.pdf instantly.

Troubleshooting the installation

If, on a commit, you get an error that includes the text This is pdfTeX and under it something along the lines of

! LaTeX Error: File `type1cm.sty' not found.

you are likely on Linux Ubuntu and want to run

sudo apt install dvipng texlive-latex-extra texlive-fonts-recommended cm-super

taken from this thread.

Credit

This package was developed over the span of multiple years (2021-2023) and across multiple research papers at university. If you produce figures for your own reports with this package, please be a kind human and acknowledge my work by crediting this repository in a footnote. For example, in LaTeX:

\footnote{All figures were made using Fiject (\url{https://github.com/bauwenst/fiject}), 
          a Python package by ir.\ Thomas Bauwens.}

Showcase

A collage of all the figures I have drawn with this code across many university projects.

The point is not how these figures look visually; you can produce equivalent plots with matplotlib and seaborn. The point is rather that the computation required to get the data in these graphs was extensive, and hence tweaking the visual parameters of these graphs would be equally expensive in matplotlib and seaborn. Also note how the graphs originate from a variety of applications, showing that fiject comes in handy for many different domains.

Line graphs

⠀

Histograms

Bar plots

Scatterplots

Tables

Metadata

Release files for fiject 2026.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fiject 2026.3.1
File Size Uploaded
fiject-2026.3.1.tar.gz 55.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fiject 2026.3.1
File Interpreter ABI Platform
fiject-2026.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 113.6 kB

Release files / fiject-2026.3.1.tar.gz

Download URL fiject-2026.3.1.tar.gz
Size 55.6 kB
Tags Source
SHA-256 checksum
How to use checksums
763d0890fd073fde29824d44a25e7b82686eafadf9afaeb74d3dd20c231ab716
BLAKE2b-256 checksum
How to use checksums
a374f5457c26c0666fd650bc2088ea5d1ab6f4fd2ebc498784efbf299532920c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

Release files / fiject-2026.3.1-py3-none-any.whl

Download URL fiject-2026.3.1-py3-none-any.whl
Size 58.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89a03b4548e9c719eff7ce82cf11dd970955541c35969a0c4d733b589bd5e778
BLAKE2b-256 checksum
How to use checksums
c230094b2f98a5dc0f29b1cc5bb634fbb48db7f89d614244ca858d672fc3be25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

Release history Release notifications | RSS feed

This release

2026.3.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page