topostats.plottingfuncs#

Plotting data.

Attributes#

Classes#

Images

Plots image arrays

Functions#

add_bounding_boxes_to_plot(→ None)

Add the bounding boxes to a plot.

Module Contents#

topostats.plottingfuncs.LOGGER#
class topostats.plottingfuncs.Images(data: numpy.array, output_dir: str | pathlib.Path, filename: str, pixel_to_nm_scaling: float = 1.0, data2: numpy.array = None, title: str = None, image_type: str = 'non-binary', image_set: str = 'core', core_set: bool = False, interpolation: str = 'nearest', cmap: str = 'nanoscope', region_properties: dict = None, zrange: list = [None, None], colorbar: bool = True, axes: bool = True, save: bool = True, save_format: str = 'png', histogram_log_axis: bool = True)[source]#

Plots image arrays

data#
output_dir#
filename#
pixel_to_nm_scaling = 1.0#
data2 = None#
title = None#
image_type = 'non-binary'#
image_set = 'core'#
core_set = False#
interpolation = 'nearest'#
cmap = 'nanoscope'#
region_properties = None#
zrange = [None, None]#
colorbar = True#
axes = True#
save = True#
save_format = 'png'#
histogram_log_axis = True#
plot_histogram_and_save()[source]#

Plot and save a histogram of the height map

Returns:

  • fig (plt.figure.Figure) – Matplotlib.pyplot figure object

  • ax (plt.axes._subplots.AxesSubplot) – Matplotlib.pyplot axes object

plot_and_save()[source]#

Plot and save the images with savefig or imsave depending on config file parameters.

Returns:

  • fig (plt.figure.Figure) – Matplotlib.pyplot figure object

  • ax (plt.axes._subplots.AxesSubplot) – Matplotlib.pyplot axes object

save_figure()[source]#

This function saves figures as plt.savefig objects.

Returns:

  • fig (plt.figure.Figure) – Matplotlib.pyplot figure object

  • ax (plt.axes._subplots.AxesSubplot) – Matplotlib.pyplot axes object

save_array_figure() None#

This function saves only the image array as an image using plt.imsave

topostats.plottingfuncs.add_bounding_boxes_to_plot(fig, ax, shape, region_properties: list, pixel_to_nm_scaling: float) None[source]#

Add the bounding boxes to a plot.

Parameters:
  • fig (plt.figure.Figure) – Matplotlib.pyplot figure object

  • ax (plt.axes._subplots.AxesSubplot.) – Matplotlib.pyplot axes object

  • shape (tuple) – Tuple of the image-to-be-plot’s shape.

  • region_properties – Region properties to add bounding boxes from.

  • pixel_to_nm_scaling (float) – The scaling factor from px to nm.

Returns:

  • fig (plt.figure.Figure) – Matplotlib.pyplot figure object.

  • ax (plt.axes._subplots.AxesSubplot) – Matplotlib.pyplot axes object.