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
figmatplotlib.figure.Figure

the figure to be plotted

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

Converts figure to a numpy array

Parameters
figmatplotlib.figure.Figure

the figure to be plotted

shapeiterable

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

Returns
arraynp.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
figmatplotlib.figure.Figure

the figure to be plotted

widthint

pixel width of the final array

heightint

pixel height of the final array

minimalbool

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

Returns
arraynp.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