tepkit.utils.mpl_tools.Figure

tepkit.utils.mpl_tools.Figure#

class tepkit.utils.mpl_tools.Figure(width: float = 1.0, height: float = 0.9, dpi: float = None, font_size=None, style='tepkit_basic', projection=None)#

Attributes#

Attribute

Default Value

Description

width

None

The ratio to the recommended width (3.334 inch = 1000 px at 300 dpi ≈ 8.47 cm),
default set to 1.0.

height

None

The ratio to the recommended height (3.334 inch = 1000 px at 300 dpi ≈ 8.47 cm),
default set to 0.9.

fig

None

ax

None

legend

None

The latest legend added by .add_legend().

colorbar

None

The latest colorbar added by .add_colorbar().

Methods#

add_legend(*args[, border_width])

A wrapper of matplotlib.pyplot.legend().

add_colorbar(*args[, width, height, border_width])

A wrapper of matplotlib.pyplot.colorbar().

adjust_margin(→ None)

A wrapper of matplotlib.pyplot.subplots_adjust().

set_locator(*args, **kwargs)

A wrapper of tepkit.utils.mpl_tools.ticker_tools.set_axes_ticker_locator().

set_formatter(*args, **kwargs)

A wrapper of tepkit.utils.mpl_tools.ticker_tools.set_axes_ticker_formatter().

save(→ None)

A wrapper of matplotlib.figure.Figure.savefig().

show([dpi])

A wrapper of matplotlib.pyplot.show().

All Members#

width: int | float
The ratio to the recommended width (3.334 inch = 1000 px at 300 dpi ≈ 8.47 cm),
default set to 1.0.
height: int | float
The ratio to the recommended height (3.334 inch = 1000 px at 300 dpi ≈ 8.47 cm),
default set to 0.9.
fig
ax
legend = None

The latest legend added by .add_legend().

colorbar = None

The latest colorbar added by .add_colorbar().

add_legend(*args, border_width: int | float | None = None, **kwargs)

A wrapper of matplotlib.pyplot.legend().

Returns:

matplotlib.legend.Legend

Features#

  • Add parameter aliases:
    • font_size: fontsize

  • Add automatic behaviors:
    • Sync the border width of the legend to the left axis.

  • Add new parameters:
    • border_width: Set the border width of the legend.

add_colorbar(*args, width: int | float = 1, height: int | float = 1, border_width: int | float | None = None, **kwargs)

A wrapper of matplotlib.pyplot.colorbar().

Returns:

matplotlib.colorbar.Colorbar

Features#

  • Add automatic behaviors:
    • Sync the border width of the colorbar to the left axis.

  • Add new parameters:
    • width and height: Change the size of the colorbar.

    • border_width: Set the border width of the colorbar.

static adjust_margin(*, top=None, right=None, bottom=None, left=None, wspace=None, hspace=None) None

A wrapper of matplotlib.pyplot.subplots_adjust().

Adjust the margin of the figure in pixels.

set_locator(*args, **kwargs)

A wrapper of tepkit.utils.mpl_tools.ticker_tools.set_axes_ticker_locator().

Set ax as self.ax.

set_formatter(*args, **kwargs)

A wrapper of tepkit.utils.mpl_tools.ticker_tools.set_axes_ticker_formatter().

Set ax as self.ax.

save(path='tepkit.figure.png', **kwargs) None

A wrapper of matplotlib.figure.Figure.savefig().

Features#

  • Add parameter aliases:
    • path: fname

  • Add parameter default value:
    • path: tepkit.figure.png

show(dpi=200)

A wrapper of matplotlib.pyplot.show().

Features#

  • Add new parameters:
    • dpi: Change the dpi of the figure before show it to avoid covering too much of the screen.