Skip to content

ggload

ggload(
    path: str | PathLike[str],
) -> PlotSpec | SupPlotsSpec

Open a plot saved with ggsave(plot, "name.ggrs").

The plot comes back as it was saved: add layers, render or save it again. Data comes back as the kind it was saved from (polars, pandas or pyarrow). Fonts stored in the file are registered under their family, over the faces of a family of that name registered before (with a warning). Opening a file never runs code from it.

Parameters:

  • path (str or PathLike) –

    A .ggrs file.

Returns:

Raises:

  • FileNotFoundError –

    If path does not exist.

  • PlotFileError –

    If the file is not a ggrust plot file, was written by a newer ggrust, or is damaged (an entry does not match its hash, is missing or too large).

Examples:

>>> from ggrust import *
>>> import os, tempfile
>>> data = {"weight": [2.6, 2.9, 3.2, 3.4, 3.6, 4.1], "mpg": [31, 28, 24, 22, 19, 15]}
>>> plot = ggplot(data, aes("weight", "mpg")) + geom_point()
>>> path = ggsave(plot, "fuel.ggrs", path=tempfile.mkdtemp())
>>> again = ggload(path) + geom_line()
>>> [layer.geom for layer in again.layers]
['point', 'line']