Welcome to the Pylustrator Documentation

Pylustrator is a software to prepare your figures for publication in a reproducible way. This means you receive a figure representing your data and alongside a generated code file that can exactly reproduce the figure as you put them in the publication, without the need to readjust things in external programs.

Pylustrator offers an interactive interface to find the best way to present your data in a figure for publication. Added formatting an styling can be saved by automatically generated code. To compose multiple figures to panels, pylustrator can compose different subfigures to a single figure.


Just get pylustrator over the pip installation:

pip install pylustrator

The package depends on:

numpy, matplotlib, pyqt5, qtpy, qtawesome, scikit-image, natsort


Using pylustrator is very easy and does not require substantial modifications to your code. Just add

1import pylustrator

before creating your first figure in your code. When calling plt.show() the plot will be displayed in a pylustrator window.

You can test pylustrator with the following example code example_pylustrator.py:

 1# import matplotlib and numpy as usual
 2import matplotlib.pyplot as plt
 3import numpy as np
 5# now import pylustrator
 6import pylustrator
 8# activate pylustrator
11# build plots as you normally would
13t = np.arange(0.0, 2, 0.001)
14y = 2 * np.sin(np.pi * t)
15a, b = np.random.normal(loc=(5., 3.), scale=(2., 4.), size=(100,2)).T
16b += a
20plt.plot(t, y)
23plt.plot(a, b, "o")
26plt.bar(0, np.mean(a))
27plt.bar(1, np.mean(b))
29# show the plot in a pylustrator window

Saving by pressing Ctrl+S or confirming to save when closing the window will add some lines of code at the end of your python script (before your plt.show()) that defines these changes:

 1#% start: automatic generated code from pylustrator
 2plt.figure(1).set_size_inches(8.000000/2.54, 8.000000/2.54, forward=True)
 3plt.figure(1).axes[0].set_position([0.191879, 0.148168, 0.798133, 0.742010])
 4plt.figure(1).axes[0].set_xlabel("data x")
 5plt.figure(1).axes[0].set_ylabel("data y")
 6plt.figure(1).axes[1].set_position([0.375743, 0.603616, 0.339534, 0.248372])
 7plt.figure(1).axes[1].set_xlabel("data x")
 8plt.figure(1).axes[1].set_ylabel("data y")
 9plt.figure(1).axes[1].set_ylim(-40.0, 90.0)
10#% end: automatic generated code from pylustrator


Because pylustrator can optionally save changes you’ve made in the GUI to update your source code, it cannot be used from a shell. To use pylustrator, call it directly from a python file and use the command line to execute.


In case you import matplotlib.pyplot to the global namespace (e.g. from matplotlib.pyplot import *), pylustrator has to be started before this import to be able to overload the show command.

Also using the show from the pylab import does not work. And is anyways discouraged, see https://matplotlib.org/stable/api/index.html?highlight=pylab#module-pylab

The good thing is that this generated code is plain matplotlib code, so it will still work when you remove pylustrator from your code! This is especially useful if you want to distribute your code and do not want to require pylustrator as a dependency.

Can styling plots be any easier?


If you encounter any bugs or unexpected behaviour, you are encouraged to report a bug in our Github bugtracker.

Citing Pylustrator

If you use Pylustrator for your publications I would highly appreciate it if you cite the Pylustrator:

  • Gerum, R., (2020). pylustrator: code generation for reproducible figures for publication. Journal of Open Source Software, 5(51), 1989. doi:10.21105/joss.01989


Pylustrator is released under the GPLv3 license. The generated output code of Pylustrator can be freely used according to the MIT license, but as it relys on Matplotlib also the Matplotlib License has to be taken into account.