plot_connections

openpnm.topotools.plot_connections(network, throats=None, ax=None, size_by=None, color_by=None, cmap='jet', color='b', alpha=1.0, linestyle='solid', linewidth=1, **kwargs)[source]

Produce a 3D plot of the network topology.

This shows how throats connect for quick visualization without having to export data to veiw in Paraview.

Parameters
  • network (GenericNetwork) – The network whose topological connections to plot

  • throats (array_like (optional)) – The list of throats to plot if only a sub-sample is desired. This is useful for inspecting a small region of the network. If no throats are specified then all throats are shown.

  • fig (Matplotlib figure handle and line property arguments (optional)) – If a fig is supplied, then the topology will be overlaid on this plot. This makes it possible to combine coordinates and connections, and to color throats differently for instance.

  • size_by (array_like (optional)) – An ndarray of throat values (e.g. alg[‘throat.rate’]). These values are used to scale the linewidth, so if the lines are too thin, then increase linewidth.

  • color_by (str or array_like (optional)) – An ndarray of throat values (e.g. alg[‘throat.rate’]).

  • cmap (str or cmap object (optional)) – The matplotlib colormap to use if specfying a throat property for color_by

  • color (str, optional (optional)) – A matplotlib named color (e.g. ‘r’ for red).

  • alpha (float (optional)) – The transparency of the lines, with 1 being solid and 0 being invisible

  • linestyle (str (optional)) – Can be one of {‘solid’, ‘dashed’, ‘dashdot’, ‘dotted’}. Default is ‘solid’.

  • linewidth (float (optional)) – Controls the thickness of drawn lines. Is used to scale the thickness if size_by is given. Default is 1. If a value is provided for size_by then they are used to scale the linewidth.

  • **kwargs (dict) – All other keyword arguments are passed on to the Line3DCollection class of matplotlib, so check their documentation for additional formatting options.

Returns

lc – Matplotlib object containing the lines representing the throats.

Return type

LineCollection or Line3DCollection

Notes

To create a single plot containing both pore coordinates and throats, consider creating an empty figure and then pass the ax object as an argument to plot_connections and plot_coordinates. Otherwise, each call to either of these methods creates a new figure.

See also

plot_coordinates

Examples

>>> import openpnm as op
>>> import matplotlib as mpl
>>> import matplotlib.pyplot as plt
>>> mpl.use('Agg')
>>> pn = op.network.Cubic(shape=[10, 10, 3])
>>> pn.add_boundary_pores()
>>> Ts = pn.throats('*boundary', mode='not')        # find internal throats
>>> fig, ax = plt.subplots()                        # create empty figure
>>> _ = op.topotools.plot_connections(network=pn,
...                                   throats=Ts)   # plot internal throats
>>> Ts = pn.throats('*boundary')                    # find boundary throats
>>> _ = op.topotools.plot_connections(network=pn,
...                                   throats=Ts,
...                                   ax=ax,
...                                   color='r')    # plot boundary throats in red