Matplotlib Hooks (xontrib.mplhooks)

Matplotlib hooks, for what its worth.

xontrib.mplhooks.buf_to_color_str(buf)[source]

Converts an RGB array to a xonsh color string.

xontrib.mplhooks.display_figure_with_iterm2(fig)[source]

Displays a matplotlib figure using iterm2 inline-image escape sequence.

Parameters:

fig : matplotlib.figure.Figure

the figure to be plotted

xontrib.mplhooks.figure_to_rgb_array(fig, shape=None)[source]

Converts figure to a numpy array

Parameters:

fig : matplotlib.figure.Figure

the figure to be plotted

shape : iterable

with the shape of the output array. by default this attempts to use the pixel height and width of the figure

Returns:

array : np.ndarray

An RGBA array of the image represented by the figure.

Note: the method will throw an exception if the given shape is wrong.

xontrib.mplhooks.figure_to_tight_array(fig, width, height, minimal=True)[source]

Converts figure to a numpy array of rgb values of tight value

Parameters:

fig : matplotlib.figure.Figure

the figure to be plotted

width : int

pixel width of the final array

height : int

pixel height of the final array

minimal : bool

whether or not to reduce the output array to minimized margins/whitespace text is also eliminated

Returns:

array : np.ndarray

An RGBA array of the image represented by the figure.

xontrib.mplhooks.show()[source]

Run the mpl display sequence by printing the most recent figure to console