The API of pylustrator is kept quite simple. Most interaction with the pylustrator package is by using the interactive interface.


This will overload the commands plt.figure() and plt.show(). If a figure is created after this command was called (directly or indirectly), a GUI window will be initialized that allows to interactively manipulate the figure and generate code in the calling script to define these changes. The window will be shown when plt.show() is called.

See also Styling Figures.


use_global_variable_names (bool, optional) – if used, try to find global variables that reference a figure and use them in the generated code.

pylustrator.load(filename: str, figure: Optional[matplotlib.figure.Figure] = None, offset: Optional[list] = None, dpi: Optional[int] = None, cache: bool = False, label: str = '')

Add contents to the current figure from the file defined by filename. It can be either a python script defining a figure, an image (filename or directly the numpy array), or an svg file.

See also Composing Figures.

  • filename (str) – The file to load. Can point to a python script file, an image file or an svg file.

  • figure (Figure, optional) – The figure where to add the loaded file. Defaults to the current figure.

  • offset (list, optional) – The offset where to import the file. The first two parts define the x and y position and the third part defines the units to use. Default is “%”, a percentage of the current figure size. It can also be “cm” or “in”.

  • cache (bool, optional) – Whether to try to cache the figure generated from the file. Only for python files. This option is experimental and may not be stable.