domplotlib

Dom’s extensions to matplotlib.

Functions:

create_figure(pagesize[, left, bottom, …])

Creates a figure with the given margins, and returns a tuple of the figure and its axes.

horizontal_legend(fig[, handles, labels, ncol])

Place a legend on the figure, with the items arranged to read right to left rather than top to bottom.

save_svg(figure, fname, *[, dpi, facecolor, …])

Save the given figure as an SVG.

transpose(iterable, ncol)

Transposes the contents of iterable so they are ordered right to left rather than top to bottom.

create_figure(pagesize, left=0.2, bottom=0.14, right=0.025, top=0.13)[source]

Creates a figure with the given margins, and returns a tuple of the figure and its axes.

Parameters
  • pagesize (PageSize)

  • left (float) – Left margin. Default 0.2.

  • bottom (float) – Bottom margin. Default 0.14.

  • right (float) – Right margin. Default 0.025.

  • top (float) – Top margin. Default 0.13.

Return type

Tuple[Figure, Axes]

horizontal_legend(fig, handles=None, labels=None, *, ncol=1, **kwargs)[source]

Place a legend on the figure, with the items arranged to read right to left rather than top to bottom.

Parameters
Return type

Legend

save_svg(figure, fname, *, dpi=None, facecolor='w', edgecolor='w', orientation='portrait', transparent=False, bbox_inches=None, pad_inches=0.1, **kwargs)[source]

Save the given figure as an SVG.

Parameters
  • figure (Figure)

  • fname (Union[str, Path, PathLike, IO]) –

    The file to save the SVG as. If format is set, it determines the output format, and the file is saved as fname. Note that fname is used verbatim, and there is no attempt to make the extension, if any, of fname match format, and no extension is appended.

    If format is not set, then the format is inferred from the extension of fname, if there is one.

  • dpi (Union[float, Literal['figure'], None]) – The resolution in dots per inch. If 'figure', use the figure’s dpi value. Default None.

  • facecolor (Union[str, Literal['auto']]) – The facecolor of the figure. If 'auto', use the current figure facecolor. Default 'w'.

  • edgecolor (Union[str, Literal['auto']]) – The edgecolor of the figure. If 'auto', use the current figure edgecolor. Default 'w'.

  • orientation (Literal['portrait', 'landscape']) – Currently only supported by the postscript backend. Default 'portrait'.

  • transparent (bool) – If True, the axes patches will all be transparent; the figure patch will also be transparent unless facecolor and/or edgecolor are specified. This is useful, for example, for displaying a plot on top of a colored background on a web page. The transparency of these patches will be restored to their original values upon exit of this function. Default False.

  • bbox_inches (Optional[str]) – Bounding box in inches: only the given portion of the figure is saved. If ‘tight’, try to figure out the tight bbox of the figure. Default None.

  • pad_inches (float) – Amount of padding around the figure when bbox_inches is ‘tight’. Default 0.1.

  • **kwargs – Additional keyword arguments passed to savefig().

transpose(iterable, ncol)[source]

Transposes the contents of iterable so they are ordered right to left rather than top to bottom.

Parameters
Return type

Iterable[~_T]

Returns

An Iterable contaning elements of the same type as iterable.