plot_coordinates#
- plot_coordinates(network, pores=None, ax=None, size_by=None, color_by=None, label_by=None, cmap='jet', color='r', alpha=1.0, marker='o', markersize=10, **kwargs)[source]#
Produce a 3D plot showing specified pore coordinates as markers.
- Parameters:
network (Network) – The network whose topological connections to plot.
pores (array_like (optional)) – The list of pores to plot if only a sub-sample is desired. This is useful for inspecting a small region of the network. If no pores are specified then all are shown.
ax (Matplotlib axis handle) – If
ax
is supplied, then the coordinates will be overlaid. This enables the plotting of multiple different sets of pores as well as throat connections fromplot_connections
.size_by (str or array_like) – An ndarray of pore values (e.g. alg[‘pore.concentration’]). These values are normalized by scaled by
markersize
. Note that this controls the marker area, so if you want the markers to be proportional to diameter you should do size_by=net[‘pore.diameter’]**2.color_by (str or array_like) – An ndarray of pore values (e.g. alg[‘pore.concentration’]).
label_by (array_like (optional)) – An array or list of values to use as labels
cmap (str or cmap object) – The matplotlib colormap to use if specfying a pore property for
color_by
color (str) – A matplotlib named color (e.g. ‘r’ for red).
alpha (float) – The transparency of the lines, with 1 being solid and 0 being invisible
marker ('s') – The marker to use. The default is a circle. Options are explained here
markersize (scalar) – Controls size of marker, default is 1.0. This value is used to scale the
size_by
argument if given.font (dict) – A dictionary of key-value pairs that are used to control the font appearance if label_by is provided.
**kwargs – All other keyword arguments are passed on to the
scatter
function of matplotlib, so check their documentation for additional formatting options.
- Returns:
pc – Matplotlib object containing the markers representing the pores.
- Return type:
PathCollection
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 toplot_connections
andplot_coordinates
. Otherwise, each call to either of these methods creates a new figure.See also
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['pore.internal'] = True >>> pn.add_boundary_pores() >>> Ps = pn.pores('internal') # find internal pores >>> fig, ax = plt.subplots() # create empty figure >>> _ = op.visualization.plot_coordinates(network=pn, ... pores=Ps, ... color='b', ... ax=ax) # plot internal pores >>> Ps = pn.pores('*boundary') # find boundary pores >>> _ = op.visualization.plot_coordinates(network=pn, ... pores=Ps, ... color='r', ... ax=ax) # plot boundary pores in red