spam.plotting package#
Submodules#
spam.plotting.greyLevelHistogram module#
Library of SPAM functions for plotting greyscale histogram Copyright (C) 2020 SPAM Contributors
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
- spam.plotting.greyLevelHistogram.plotGreyLevelHistogram(im, greyRange=None, bins=256, density=False, series=False, showGraph=False)[source]#
Computes a histogram and optionally shows it with matplotlib
- Parameters:
im (an n-d numpy array.) – If series = True, the first dimension is interpreted as the different times
greyRange (2-component list, optional) – Value of bottom and top of histogram, Default is guessed from data type, min and max for float
bins (int, optional) – Number of bins to split the range into
density (bool, optional) – Return a PDF or counts? Default = False
series (bool, optional) – Is the input a series of images? Default = False
showGraph (bool, optional) – Show graph? Default = False
- Returns:
midBins (1D numpy.array) – The middle value of the bins
counts (1D numpy.array) – Number of counts for each bin (possibly normalised, if requested)
spam.plotting.multivariateGaussians module#
Library of SPAM functions for plotting multivariate gaussians Copyright (C) 2020 SPAM Contributors
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
spam.plotting.orientationPlotter module#
Library of SPAM functions for plotting orientations in 3D Copyright (C) 2020 SPAM Contributors
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
- spam.plotting.orientationPlotter.plotOrientations(orientations_zyx, projection='lambert', plot='both', binValueMin=None, binValueMax=None, binNormalisation=False, numberOfRings=9, pointMarkerSize=8, cmap=<matplotlib.colors.LinearSegmentedColormap object>, title='', subtitle={'bins': '', 'points': ''}, saveFigPath=None)[source]#
Main function for plotting 3D orientations. This function plots orientations (described by unit-direction vectors) from a sphere onto a plane.
One useful trick for evaluating these orientations is to project them with a “Lambert equal area projection”, which means that an isotropic distribution of angles is projected as equally filling the projected space.
- Parameters:
orientations (Nx3 numpy array of floats) – Z, Y and X components of direction vectors. Non-unit vectors are normalised.
projection (string, optional) –
- Selects different projection modes:
lambert : Equal-area projection, default and highly reccommended. See https://en.wikipedia.org/wiki/Lambert_azimuthal_equal-area_projection
equidistant : equidistant projection
plot (string, optional) –
- Selects which plots to show:
points : shows projected points individually bins : shows binned orientations with counts inside each bin as colour both : shows both representations side-by-side, default
title (string, optional) – Plot main title. Default = “”
subtitle (dictionary, optional) –
- Sub-plot titles:
points : Title for points plot. Default = “” bins : Title for bins plot. Default = “”
binValueMin (int, optional) – Minimum colour-bar limits for bin view. Default = None (i.e., auto-set)
binValueMax (int, optional) – Maxmum colour-bar limits for bin view. Default = None (i.e., auto-set)
binNormalisation (bool, optional) – In binning mode, should bin counts be normalised by mean counts on all bins or absolute counts?
cmap (matplotlib colour map, optional) – Colourmap for number of counts in each bin in the bin view. Default =
matplotlib.pyplot.cm.RdBu_r
numberOfRings (int, optional) – Number of rings (i.e., radial bins) for the bin view. The other bins are set automatically to have uniform sized bins using an algorithm from Jacquet and Tabot. Default = 9 (quite small bins)
pointMarkerSize (int, optional) – Size of points in point view (5 OK for many points, 25 good for few points/debugging). Default = 8 (quite big points)
saveFigPath (string, optional) – Path to save figure to – stops the graphical plotting. Default = None
- Return type:
None – A matplotlib graph is created and show()n
Note
Authors: Edward Andò, Hugues Talbot, Clara Jacquet and Max Wiebicke
- spam.plotting.orientationPlotter.distributionDensity(F, step=50, lim=None, color=None, viewAnglesDeg=[25, 45], title=None, saveFigPath=None)[source]#
Creates the surface plot of the distribution density of the deviatoric fabric tensor F
- Parameters:
F (3x3 array of floats) – deviatoric fabric tensor. Usually obtained from spam.label.fabricTensor
step (int, optional) – Number of points for the surface plot Default = 50
lim (float, optional) – Limit for the axes of the plot Default = None
color (colormap class, optional) – Colormap class from matplotlib module See ‘https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html’ for options Example : matplotlib.pyplot.cm.viridis Default = matplotlib.pyplot.cm.Reds
viewAnglesDeg (2-component list, optional) – Set initial elevation and azimuth for this 3D plot
title (str, optional) – Title for the graph Default = None
saveFigPath (string, optional) – Path to save figure to. Default = None
- Return type:
None – A matplotlib graph is created and shown
Note
see [Kanatani, 1984] for more information on the distribution density function for the deviatoric fabric tensor
- spam.plotting.orientationPlotter.plotSphericalHistogram(orientations, subDiv=3, reflection=True, maxVal=None, verbose=True, color=None, viewAnglesDeg=[25, 45], title=None, saveFigPath=None)[source]#
Generates a spherical histogram for vectorial data, binning the data into regions defined by the faces of an icosphere (convex polyhedron made from triangles).
The icosphere is built from starting from an icosahedron (polyhedron with 20 faces) and then making subdivision on each triangle. The number of faces is 20*(4**subDiv).
- Parameters:
orientations (Nx3 numpy array) – Vectors to be plotted
subDiv (integer, optional) – Number of times that the initial icosahedron is divided. Default: 3
reflection (bool, optional) – If true, the histogram takes into account the reflection of the vectors Default = True.
maxVal (int, optional) – Maximum colour-bar limits for bin view. Default = None (i.e., auto-set)
verbose (bool, optional) – Print the evolution of the plot Defautl = False
color (colormap class, optional) – Colormap class from matplotlib module See ‘https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html’ for options Example : matplotlib.pyplot.cm.viridis Default = matplotlib.pyplot.cm.viridis_r
viewAnglesDeg (2-component list, optional) – Set initial elevation and azimuth for this 3D plot
title (str, optional) – Title for the graph Default = None
saveFigPath (string, optional) – Path to save figure to, including the name and extension of the file. If it is not given, the plot will be shown but not saved. Default = None
- Return type:
None – A matplotlib graph is created and shown
spam.plotting.particleSizeDistribution module#
Library of SPAM functions for plotting a particle size distribution Copyright (C) 2020 SPAM Contributors
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
- spam.plotting.particleSizeDistribution.plotParticleSizeDistribution(inputRadii, range=None, logScaleX=False, logScaleY=False, units='px', bins=256, cumulative=False, cumulativePassing=True, mode='particles', returnValues=False, plot=True, legendNames=None)[source]#
This functions draws particle size distributions. There are a number of options, which are detailed below. For a typical geotechnical grading curve the following options (not default) should be used:
cumulative=True,
cumulativePassing=True,
mode=”mass”,
logScaleX=True,
logScaleY=False
- Parameters:
inputRadii (list of particle radii) – This can be in any units, but if they are not in pixels, you should also set the “units” variable so that the label on the x-axis is correct
range (two-component list (optional, default = [min and max] diameters or calculated volumes)) – Contains range for histogram, top and bottom.
logScaleX (Bool (optional, default = False)) – Log-scale X axis
logScaleY (Bool (optional, default = False)) – Log-scale Y axis
units (string (optional, default = "px")) – Units to write on the x-axis
bins (int (optional, default = 256)) – Number of bins for the histogram, i.e., the number of points
cumulative (bool (optional, default = False)) – Draw a cumulative histogram, or just a regular histogram?
cumulativePassing (bool (optional, default = True)) – If you aked for a cumulative histogram, do you want it in “passing” the sieve mode, or in “retained” on the sieve mode?
mode (string (options, default = "massExact")) –
Should the cumulative graphs be based on number of particles, or particle volume/mass? In sieving ones measures mass. Options:
”particles”
”mass”
”volume” – the same as above
returnValues (bool (optional, default=False)) – return size and count vectors
plot (bool (optional, default=True)) – actually draw a matplotlib graph
legendNames (list of strings (optional, default=None)) – Description of distribution
- Return type:
None – just a matplotlib graph
spam.plotting.tetrahedraPlotter module#
Library of SPAM functions for plotting a tetrahedral mesh Copyright (C) 2020 SPAM Contributors
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
- spam.plotting.tetrahedraPlotter.plotDelaunay3D(points, connectivity, center_fraction, tet_strains, strain_range, axstr=1)[source]#
Plots Delaunay triangulation with strains.
- Parameters:
points (Particles' x,y,z coordinates at original step in Np x 3 array. (Just used for plotting))
connectivity (Delaunay triangulation generated by mesh_sandbox.voro_to_connectivity_3d)
center_fraction (Fraction of center of specimen to plot.)
tet_strains (List of strain tensors in each tetrahedron, from mesh_sandbox.voro_connectivity_to_strain_3d.)
strain_range (Upper and lower bounds for plotting strain.)
axstr (flag for the strain component to plot) – 1 = ‘XX’ component 2 = ‘YY’ component 3 = ‘ZZ’ component 4 = volumetric strain, XX+YY+ZZ 5 = equivalent strain, sqrt(2/3*e_{ij}^{dev}e_{ij}^{dev})
- Return type:
Nothing, just creates a plot right now
Example
mesh_sandbox.voro_plot_connectivity_3d(points,connectivity,0.02,tet_sym,0.02,’Z’)