Image class#

class pyPLUTO.Image[source]#

Description of the Image class.

The Image class is a facade for the different managers that handle the various aspects of plotting, such as creating axes, displaying data, adding legends, text, fieldlines, colorbars, and more. It provides a unified interface for creating and managing plots in a figure. The attributes are handled through the ImageState class, which is a dataclass that stores the state of the image, such as the figure, axes, and other properties. The Image class uses a mediator pattern to manage the interactions between the different managers and the state.

Initialize the Image class.

Ihat creates a new figure and sets the LaTeX conditions, as well as the matplotlib style. Every Image is associated to a figure object and only one in order to avoid confusion between images and figures. If you want to create multiple figures, you have to create multiple Image objects.

Parameters:
- close: bool, default True

If True, the existing figure with the same window number is closed.

- fig: Figure | None, default None

The figure instance. If not None, the figure is used (only if we need to associate an Image to an existing figure).

- figsize: list[float], default varies

Sets the figure size. The default is [6*sqrt(ncol), 5*sqrt(nrow)], computed from the number of rows and columns (or [8,5] for a single plot).

- fontsize: float, default 17.0

Sets the fontsize for all the axis components.

- fontweight: str, default ‘normal’

The font weight for all the axis components.

- LaTeX: bool | str, default False

The LaTeX option. Is True is selected, the default LaTeX font is used. If ‘pgf’ is selected, the pgf backend is used to save pdf figures with minimal file size. If XeLaTeX is not installed and the ‘pgf’ option is selected, the LaTeX option True is used as backup strategy.

- numcolors: int, default 10

The number of colors in the colorscheme. The default number is 10, but the full list contains 24 colors (+ black or white).

- nwin: int, default 1

The window number.

- replace: bool, default False

If True, the existing figure with the same window is replaced.

- style: str, default ‘default’

The style of the figure. Possible values are: ‘seaborn’, ‘ggplot’, ‘fivethirtyeight’, ‘bmh’, ‘grayscale’, ‘dark_background’, ‘classic’, etc.

- suptitle: str, default None

Creates a figure title over all the subplots.

- suptitlesize: str | int, default ‘large’

The figure title size.

- tight: bool, default True

Enables/disables tight layout options for the figure. In case of a highly customized plot (e.g. ratios or space between rows and columns) the option is set by default to False since that option would not be available for standard matplotlib functions.

- text: bool | None, default None

Controls output verbosity. None (default) logs the window number at INFO level. False silences all output. True enables full DEBUG logging.

- withblack: bool, default False

If True, the black color is used as first color.

- withwhite: bool, default False

If True, the white color is used as first color.

Returns:
  • None

Examples

  • Example #1: create an empty image

    >>> import pyPLUTO as pp
    >>> I = pp.Image()
    
  • Example #2: create an image with the pgf backend

    >>> import pyPLUTO as pp
    >>> I = pp.Image(LaTeX="pgf")
    
  • Example #3: create an image with the LaTeX option True

    >>> import pyPLUTO as pp
    >>> I = pp.Image(LaTeX=True)
    
  • Example #4: create an image with fixed size

    >>> import pyPLUTO as pp
    >>> I = pp.Image(figsize=[5, 5])
    
  • Example #5: create an image with a title

    >>> import pyPLUTO as pp
    >>> I = pp.Image(suptitle="Title")