lgca.square_plotting.SquarePlotMixin

class lgca.square_plotting.SquarePlotMixin

Bases: object

Plotting helpers for square lattice LGCAs.

plot_density(density=None, channels=slice(None, None, None), figindex=None, figsize=None, tight_layout=True, cmap='viridis', vmax=None, edgecolor='None', cbar=True, cbarlabel='Particle number $n$')

Plot particle density in the lattice. A color bar on the right side shows the color coding of density values. Empty nodes are white.

Parameters:
  • cbar (bool, default=True) – Whether to draw a colorbar for the plot on an extra axis to the right.

  • cbarlabel (str, default='Particle number $n$') – Label of the colorbar.

  • channels (slice) – Indices of the velocity/resting channels that should be considered for the density calculation if density is None.

  • cmap (str or matplotlib.colors.Colormap, default=’viridis’) – Color map for the density values. Used to construct a discretized version of the colormap.

  • colorbarwidth (float) – Width of the additional axis for the color bar, passed to mpl_toolkits.axes_grid1.axes_divider.AxesDivider.append_axes().

  • density (numpy.ndarray, optional) – Particle density values for a lattice to plot. If set to None and a simulation has been performed before, the result of the simulation is plotted. Dimensions: self.dims.

  • edgecolor ({matplotlib color, ‘None’, ‘auto’}, default ‘None’) – Color of the polygon edges for the lattice nodes.

  • figindex (int or str, optional) – An identifier for the figure (passed to matplotlib.pyplot.figure()). If it is a string, the figure label and the window title is set to this value.

  • figsize (tuple of int or tuple of float with 2 elements, default=(8,8)) – Desired figure size in inches (x, y).

  • tight_layout (bool, default=True) – If matplotlib.figure.Figure.tight_layout() is called for padding between and around subplots.

  • vmax (int, optional) – Maximum density value for the color scaling. The minimum value is zero. All density values higher than vmax are drawn in the color at the end of the color bar. If None, vmax is set to the number of channels self.K.

  • **kwargs – Arguments to be passed on to setup_figure().

Returns:

Density plot over time.

See also

setup_figure

Manage basic layout.

setup_figure(figindex=None, figsize=(8, 8), tight_layout=True)

Create a matplotlib figure and manage basic layout.

Used by the class’ plotting functions.

Parameters:
  • figindex (int or str, optional) – An identifier for the figure (passed to matplotlib.pyplot.figure()). If it is a string, the figure label and the window title is set to this value.

  • figsize (tuple of int or tuple of float with 2 elements, default=(8,8)) – Desired figure size in inches (x, y).

  • tight_layout (bool, default=True) – If matplotlib.figure.Figure.tight_layout() is called for padding between and around subplots.

Returns:

  • fig (matplotlib.figure.Figure) – New customized figure.

  • ax (matplotlib.axes.Axes) – Drawing axis associated with fig.

See also

plot_density

Plot particle density over time.

plot_flux

Plot flux over time.