Plot Tools#
- flickerprint.tools.plot_tools.annotate_axis(ax, label, pos=None, **fontKwargs)#
Place a label in the figure.
This defaults to the top left, useful for labelling sub-figures.
- flickerprint.tools.plot_tools.create_axes(n_axes, col_wrap=4, axes_height=4, fig_width=None, aspect=1.0, **subplot_kw) Tuple[Figure, List[Axes]] #
Create a figure and sub-axes, while specifing the size of the sub figures.
This emulated the behaviour of the seaborn facet grid, where we give a size for the individual figures rather than the overall plot.
The remaining axes are blanked using plt.axis(‘off’)
Only one of
axes_height
orfig_width
should be not None as these options conflict. To maintain backwards compatibility,axes_height
will overridefig_width
.- Parameters:
n_axes (int) – Number of sub-axes to create
col_wrap (int) – How many columns in the figure, next axes will go into new rows.
axes_height (float or None) – Height of the axes, in inches by default
fig_width (float or None) – Total width of the figure, conflicts with axes height
aspect (float) – Width/Height ratio of the sub-axes
- Returns:
The axes are returned in a flat array, [0,…,n_axes-1]
- Return type:
fig, [axes]
- flickerprint.tools.plot_tools.create_figure_directory(name) Path #
Create a figure directory within the project structure.
- flickerprint.tools.plot_tools.despine_axis(ax)#
Remove the top and right axis.
This emulates seaborn.despine, but doesn’t require the modules.
- flickerprint.tools.plot_tools.force_integer_ticks(ax, x=False, y=False)#
Force the tick marks on either of the axes to be in integers.
- flickerprint.tools.plot_tools.format_si(number, precision=3, s='', latex=False)#
Add SI metric prefix to the number and print to a given specification.
If the magnitude of the number is not within the range 10^-24 to 10^24 then we simply return the number in scientific notation.
- flickerprint.tools.plot_tools.hide_axis_lables(ax)#
Given an axis, remove the text and spacing used in the tick marks.
- flickerprint.tools.plot_tools.image_comp(images: List[ndarray], save_name: Path, titles: List[str] | None = None, axes_height=4, fig_width=None, col_wrap=4, cmap='inferno', norm=False)#
Plot several images for comparison.
Intended to be a one-line convince to compare plots. TODO: Add colour-bar and equalisation options.
- flickerprint.tools.plot_tools.polar2cart(theta, radii)#
Convert polar angles to (x, y).
- flickerprint.tools.plot_tools.save(save_name: Path, args=None, additional_metadata=None, padding=0.15, tl_padding=1.08, fig=None, despine=True, dpi=330)#
Save the figure with metadata and crop the boundaries.
- flickerprint.tools.plot_tools.save_figure_and_trim(save_name: Path, args=None, additional_metadata=None, padding=0.15, tl_padding=1.08, fig=None, despine=True, dpi=330)#
Save the figure with metadata and crop the boundaries.
- flickerprint.tools.plot_tools.set_labels(axs, ylabels=None, xlabels=None, **fontkwargs)#
Given a set of axes, label those that are in the outermost positions.
We use the in-built methods on the axes to create y-labels on the left most axes and add x-labels to the bottom row.