PlottingFunctions module

Created on Tue Sep 19 11:02:24 2023

Class related to making figure-quality plots

Probably best to set your default sans-serif font to Helvetica before you make figures: https://fowlerlab.org/2019/01/03/changing-the-sans-serif-font-to-helvetica/

The maximum published width for a one-column figure is 3.33 inches (240 pt). The maximum width for a two-column figure is 6.69 inches (17 cm). The maximum depth of figures should be 8 ¼ in. (21.1 cm).

panel labels are 8 point font, ticks are 7 point font, annotations and legends are 6 point font

@author: jbeckwith

class PlottingFunctions.Plotter(poster=False)

Bases: object

histogram_plot(axs, data, bins, xlim=None, ylim=None, histcolor='gray', xaxislabel='x axis', alpha=1, histtype='bar', density=True)

histogram_plot function takes data and makes a histogram

Parameters:
  • data (np.1darray) – data array

  • bins (np.1darray) – bin array

  • xlim (boolean or list of two floats) – default is None (which computes min/max of x), otherwise provide a min/max

  • ylim (boolean or list of two floats) – default is None (which computes min/max of y), otherwise provide a min/max

  • histcolor (string) – histogram colour (default is gray)

  • xaxislabel (string) – x axis label (default is ‘x axis’)

  • alpha (float) – histogram transparency (default 1)

  • histtype (string) – histogram type, default bar

  • density (boolean) – if to plot as pdf, default True

Returns:

axs (axis) – axis object

image_plot(axs, data, vmin=None, vmax=None, cmap='binary', cbar='on', cbarlabel='intensity', label='', labelcolor='black', pixelsize=69, scalebarsize=5000, scalebarlabel='5$\\,\\mu$m', alpha=1)

image_plot function takes image data and makes an image plot

Parameters:
  • data (np.2darray) – image

  • vmin (float) – minimum pixel intensity displayed (default 0.1%)

  • vmax (float) – minimum pixel intensity displayed (default 99.9%)

  • cmap (string) – colour map used; default gray)

  • cbarlabel (string) – colour bar label; default ‘photons’

  • label (string) – is any annotation

  • labelcolor (string) – annotation colour

  • pixelsize (float) – pixel size in nm for scalebar, default 110

  • scalebarsize (float) – scalebarsize in nm, default 5000

  • scalebarlabel (string) – scale bar label, default 5 um

Returns:

axs (axis) – axis object

kusumi_plot(axs, deltaT, MSD, xlim=None, ylim=None, label='', edgecolor='k', facecolor='white', alpha=1, s=5, lw=0.75, xaxislabel='$\\Delta$t', yaxislabel='MSD/4$\\Delta$t')

kusumi_plot function takes MSD and deltaT and makes a kusumi plot

Parameters:
  • axs (axis) – axis object

  • data (np.2darray) – image

  • deltaT (np.1darray) – deltaT array

  • MSD (np.1darray) – MSD array

  • xlim (np.1darray) – x limits

  • ylim (np.1darray) – y limits

  • label (str) – label of data

  • edgecolor (str) – colour of edges (default black)

  • facecolor (str) – colour of face (default white)

  • alpha (float) – transparency of scatter point (default 1)

  • s (float) – size of data point

  • lw (float) – line with (default 0.75)

  • xaxislabel (string) – x axis label (default $Delta$t)

  • yaxislabel (string) – x axis label (default MSD/4$Delta$t)

Returns:

axs (axis) – axis object

line_plot(axs, x, y, xlim=None, ylim=None, color='k', lw=0.75, label='', xaxislabel='x axis', yaxislabel='y axis', ls='-')

line_plot function takes data and makes a line plot

Parameters:
  • x (np.1darray) – x data

  • y (np.1darray) – y data

  • None (ylim is y limits; default is)

  • None

  • black (color is line colour; default is)

  • width (lw is line)

  • nothing (label is label; default is)

  • label (yaxislabel is y axis)

  • label

Returns:

axs is axis object

multi3Dtrack_plot(axs, coordinates_dict, lw=0.75, label='', xaxislabel='x axis', yaxislabel='y axis', zaxislabel='z axis', ls='-')
one_column_plot(npanels=1, ratios=[1], height=None, threedim=False)

one_column_plot function takes data and makes a one-column width figure

Parameters:
  • npanels (int) – number of panels in the figure

  • ratios (np.1darray) – size ratios of panels

  • height (float) – figure height

  • threedim (boolean) – if True, make a 3D projection figure

Returns:
  • fig (figure object) – figure

  • axs (axes object) – axes

scatter_plot(axs, x, y, xlim=None, ylim=None, label='', edgecolor='k', facecolor='white', s=5, lw=0.75, xaxislabel='x axis', yaxislabel='y axis', alpha=1)

scatter_plot function takes scatter data and makes an scatter plot

Parameters:
  • xdata (np.1darray) – scatter points, x

  • ydata (np.1darray) – scatter points, y

  • xlim (np.1darray) – x limits

  • ylim (np.1darray) – y limits

  • label (string) – any annotation

  • edgecolor (string) – colour of scatter plot edges

  • facecolor (string) – colour of scatter point faces

  • alpha (float) – transparency of points

Returns:

axs (axis) – axis object

two_column_plot(nrows=1, ncolumns=1, heightratio=[1], widthratio=[1], height=0)

two_column_plot function takes data and makes a two-column width figure

Parameters:
  • nrows (int) – number of rows

  • ncolumns (int) – number of columns

  • heightratio (np.1darray) – array of same length as number of rows

  • widthratio (np.1darray) – array of same length as number of columns

  • height (float) – if set, figure will be this height

Returns:
  • fig (figure object) – figure

  • axs (axes object) – axes