plotting module

Classes:

StereoNet(**kwargs)

Plot features on stereographic projection

StereoGrid(**kwargs)

The class to store values with associated uniformly positions.

RosePlot(**kwargs)

RosePlot class for rose histogram plotting.

VollmerPlot(*args, **kwargs)

Represents the triangular fabric plot (Vollmer, 1989).

RamsayPlot(*args, **kwargs)

Represents the Ramsay deformation plot.

FlinnPlot(*args, **kwargs)

Represents the Ramsay deformation plot.

HsuPlot(*args, **kwargs)

Represents the Hsu fabric plot.

Functions:

quicknet(*args, **kwargs)

Function to quickly show or save StereoNet from args

class apsg.plotting.StereoNet(**kwargs)

Bases: object

Plot features on stereographic projection

Keyword Arguments
  • title (str) – figure title. Default None.

  • title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.

  • tight_layout (bool) – Matplotlib figure tight_layout. Default False

  • kind (str) – Equal area (“equal-area”, “schmidt” or “earea”) or equal angle (“equal-angle”, “wulff” or “eangle”) projection. Default is “equal-area”

  • hemisphere (str) – “lower” or “upper”. Default is “lower”

  • overlay_position (tuple or Pair) – Position of overlay X, Y, Z given by Pair. X is direction of linear element, Z is normal to planar. Default is (0, 0, 0, 0)

  • rotate_data (bool) – Whether data should be rotated together with overlay. Default False

  • minor_ticks (None or float) – Default None

  • major_ticks (None or float) – Default None

  • overlay (bool) – Whether to show overlay. Default is True

  • overlay_step (float) – Grid step of overlay. Default 15

  • overlay_resolution (float) – Resolution of overlay. Default 181

  • clip_pole (float) – Clipped cone around poles. Default 15

  • grid_type (str) – Type of contouring grid “gss” or “sfs”. Default “gss”

  • grid_n (int) – Number of counting points in grid. Default 3000

Examples

>>> l = linset.random_fisher(position=lin(120, 40))
>>> s = StereoNet(title="Random linear features")
>>> s.contour(l)
>>> s.line(l)
>>> s.show()
clear()

Clear plot

to_json()

Return stereonet as JSON dict

classmethod from_json(json_dict)

Create stereonet from JSON dict

save(filename)

Save stereonet to pickle file

Parameters

filename (str) – name of picke file

classmethod load(filename)

Load stereonet from pickle file

Parameters

filename (str) – name of picke file

render2fig(fig)

Plot stereonet to already existing figure or subfigure

Parameters

fig (Figure) – A mtplotlib Figure artist

format_coord(x, y)

Format stereonet coordinates

show()

Show stereonet

savefig(filename='stereonet.png', **kwargs)

Save stereonet figure to graphics file

Keyword Arguments

filename (str) – filename

All others kwargs are passed to matplotlib Figure.savefig

line(*args, **kwargs)

Plot linear feature(s) as point(s)

Parameters

feature (Vector3 or Vector3Set like) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • mec (color) – Set the edge color. Default None

  • mfc (color) – Set the face color. Default None

  • mew (float) – Set the marker edge width. Default 1

  • ms (float) – Set the marker size. Default 6

  • marker (str) – Marker style string. Default “o”

  • ls (str) – Line style string (only for multiple features). Default None

pole(*args, **kwargs)

Plot pole of planar feature(s) as point(s)

Parameters

feature (Foliation or FoliationSet) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • mec (color) – Set the edge color. Default None

  • mfc (color) – Set the face color. Default None

  • mew (float) – Set the marker edge width. Default 1

  • ms (float) – Set the marker size. Default 6

  • marker (str) – Marker style string. Default “o”

  • ls (str) – Line style string (only for multiple features). Default None

vector(*args, **kwargs)

Plot vector feature(s) as point(s)

Note: Markers are filled on lower and open on upper hemisphere.

Parameters

feature (Vector3 or Vector3Set like) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • mec (color) – Set the edge color. Default None

  • mfc (color) – Set the face color. Default None

  • mew (float) – Set the marker edge width. Default 1

  • ms (float) – Set the marker size. Default 6

  • marker (str) – Marker style string. Default “o”

  • ls (str) – Line style string (only for multiple features). Default None

scatter(*args, **kwargs)

Plot vector-like feature(s) as point(s)

Note: This method is using scatter plot to allow variable colors

or sizes of points

Parameters

feature (Vector3 or Vector3Set like) –

Keyword Arguments
  • s (list or array) –

  • c (list or array) –

  • alpha (scalar) – Set the alpha value. Default None

  • linewidths (float) – The linewidth of the marker edges. Default 1.5

  • marker (str) – Marker style string. Default “o”

  • cmap (str) – Mtplotlib colormap. Default None

  • legend (bool) – Whether to show legend. Default False

  • num (int) – NUmber of legend items. Default “auto”

great_circle(*args, **kwargs)

Plot planar feature(s) as great circle(s)

Note: great_circle has also alias gc

Parameters

feature (Foliation or FoliationSet) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

gc(*args, **kwargs)

Plot planar feature(s) as great circle(s)

Note: great_circle has also alias gc

Parameters

feature (Foliation or FoliationSet) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

arc(*args, **kwargs)

Plot arc bewtween vectors along great circle(s)

Note: You should pass several features in connection order

Parameters

feature (Vector3 or Vector3Set like) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

pair(*args, **kwargs)

Plot pair feature(s) as great circle and point

Parameters

feature (Pair or PairSet) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

  • line_marker (str) – Marker style string for point. Default “o”

fault(*args, **kwargs)

Plot fault feature(s) as great circle and arrow

Note: Arrow is styled according to default arrow config

Parameters

feature (Fault or FaultSet) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

hoeppner(*args, **kwargs)

Plot fault feature(s) on Hoeppner (tangent lineation) plot

Note: Arrow is styled according to default arrow config

Parameters

feature (Fault or FaultSet) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

arrow(*args, **kwargs)

Plot arrow at position of first argument and oriented in direction of second

Note: You should pass two features

Parameters

feature (Vector3 or Vector3Set like) –

Keyword Arguments
  • color (color) – Set the color of the arrow. Default None

  • width (int) – Width of arrow. Default 2

  • headwidth (int) – Width of arrow head. Default 5

  • pivot (str) – Arrow pivot. Default “mid”

  • units (str) – Arrow size units. Default “dots”

tensor(*args, **kwargs)

Plot principal planes or principal directions of tensor

Parameters

feature (OrientationTensor3 like) –

Keyword Arguments
  • planes (bool) – When True, plot principal planes, otherwise principal directions. Default True

  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color. Default is red, green, blue for s1, s2, s3

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

  • mew (float) – Set the marker edge width. Default 1

  • ms (float) – Set the marker size. Default 9

  • marker (str) – Marker style string. Default “o”

contour(*args, **kwargs)

Plot filled contours using modified Kamb contouring technique with exponential smoothing.

Parameters

feature (Vector3Set like) –

Keyword Arguments
  • levels (int or list) – number or values of contours. Default 6

  • cmap – matplotlib colormap used for filled contours. Default “Greys”

  • colorbar (bool) – Show colorbar. Default False

  • alpha (float) – transparency. Default None

  • antialiased (bool) – Default True

  • sigma (float) – If None it is automatically calculated

  • sigmanorm (bool) – If True scaled counts are normalized by sigma. Default True

  • trimzero (bool) – Remove values equal to 0. Default True

  • clines (bool) – Show contour lines instead filled contours. Default False

  • linewidths (float) – contour lines width

  • linestyles (str) – contour lines style

  • show_data (bool) – Show data as points. Default False

  • data_kws (dict) – arguments passed to point factory when show_data True

class apsg.plotting.StereoGrid(**kwargs)

Bases: object

The class to store values with associated uniformly positions.

StereoGrid is used to calculate continous functions on sphere e.g. density distribution.

Keyword Arguments
  • kind (str) – Equal area (“equal-area”, “schmidt” or “earea”) or equal angle (“equal-angle”, “wulff” or “eangle”) projection. Default is “equal-area”

  • hemisphere (str) – “lower” or “upper”. Default is “lower”

  • overlay_position (tuple or Pair) – Position of overlay X, Y, Z given by Pair. X is direction of linear element, Z is normal to planar. Default is (0, 0, 0, 0)

  • rotate_data (bool) – Whether data should be rotated together with overlay. Default False

  • minor_ticks (None or float) – Default None

  • major_ticks (None or float) – Default None

  • overlay (bool) – Whether to show overlay. Default is True

  • overlay_step (float) – Grid step of overlay. Default 15

  • overlay_resolution (float) – Resolution of overlay. Default 181

  • clip_pole (float) – Clipped cone around poles. Default 15

  • grid_type (str) – Type of contouring grid “gss” or “sfs”. Default “gss”

  • grid_n (int) – Number of counting points in grid. Default 3000

Note: Euclidean norms are used as weights. Normalize data if you dont want to use weigths.

min()

Returns minimum value of the grid

max()

Returns maximum value of the grid

min_at()

Returns position of minimum value of the grid as Lineation

max_at()

Returns position of maximum value of the grid as Lineation

calculate_density(features, **kwargs)

Calculate density distribution of vectors from FeatureSet object.

The modified Kamb contouring technique with exponential smoothing is used.

Parameters
  • sigma (float) – if none sigma is calculated automatically. Default None

  • sigmanorm (bool) – If True counting is normalized to sigma multiples. Default True

  • trimzero – if True, zero contour is not drawn. Default True

density_lookup(v)

Calculate density distribution value at position given by vector

Note: you need to calculate density before using this method

Parameters

v – Vector3 like object

Keyword Arguments

p (int) – power. Default 2

apply_func(func, *args, **kwargs)

Calculate values of user-defined function on sphere.

Function must accept Vector3 like (or 3 elements array) as first argument and return scalar value.

Parameters
  • func (function) – function used to calculate values

  • *args – passed to function func as args

  • **kwargs – passed to function func as kwargs

contourf(*args, **kwargs)

Draw filled contours of values using tricontourf.

Keyword Arguments
  • levels (int or list) – number or values of contours. Default 6

  • cmap – matplotlib colormap used for filled contours. Default “Greys”

  • colorbar (bool) – Show colorbar. Default False

  • alpha (float) – transparency. Default None

  • antialiased (bool) – Default True

contour(*args, **kwargs)

Draw contour lines of values using tricontour.

Keyword Arguments
  • levels (int or list) – number or values of contours. Default 6

  • cmap – matplotlib colormap used for filled contours. Default “Greys”

  • colorbar (bool) – Show colorbar. Default False

  • alpha (float) – transparency. Default None

  • antialiased (bool) – Default True

  • linewidths (float) – contour lines width

  • linestyles (str) – contour lines style

plotcountgrid(**kwargs)

Show counting grid.

angmech(faults, **kwargs)

Implementation of Angelier-Mechler dihedra method

Parameters

faultsFaultSet of data

Kwargs:

method: ‘probability’ or ‘classic’. Classic method assigns +/-1 to individual positions, while ‘probability’ returns maximum likelihood estimate. Other kwargs are passed to contourf

class apsg.plotting.RosePlot(**kwargs)

Bases: object

RosePlot class for rose histogram plotting.

Keyword Arguments
  • title (str) – figure title. Default None

  • title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.

  • bins (int) – Number of bins. Default 36

  • axial (bool) – Directional data are axial. Defaut True

  • density (bool) – Use density instead of counts. Default False

  • pdf (bool) – Plot Von Mises density function instead histogram. Default False

  • pdf_res (int) – Resolution of pdf. Default 901

  • kappa (float) – Shape parameter of Von Mises pdf. Default 250

  • scaled (bool) – Bins scaled by area instead value. Default False

  • ticks (bool) – show ticks. Default True

  • grid (bool) – show grid lines. Default False

  • grid_kws (dict) – Dict passed to Axes.grid. Default {}

  • plot. (Other keyword arguments are passed to matplotlib) –

Examples

>>> v = vec2set.random_vonmises(position=120)
>>> p = RosePlot(grid=False)
>>> p.pdf(v)
>>> p.bar(v, fc='none', ec='k', lw=1)
>>> p.muci(v)
>>> p.show()
clear()

Clear plot

to_json()

Return rose plot as JSON dict

classmethod from_json(json_dict)

Create rose plot from JSON dict

save(filename)

Save stereonet to pickle file

Parameters

filename (str) – name of picke file

classmethod load(filename)

Load stereonet from pickle file

Parameters

filename (str) – name of picke file

render2fig(fig)

Plot stereonet to already existing figure or subfigure

Parameters

fig (Figure) – A mtplotlib Figure artist

show()

Show rose plot

savefig(filename='roseplot.png', **kwargs)

Save rose plot figure to graphics file

Keyword Arguments

filename (str) – filename

All others kwargs are passed to matplotlib Figure.savefig

bar(*args, **kwargs)

Plot rose histogram of angles

Parameters

feature (Vector2Set) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ec (color) – Patch edge color. Default None

  • fc (color) – Patch face color. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

  • legend (bool) – Whether to show legend. Default False

pdf(*args, **kwargs)

Plot Von Mises probability density function from angles

Parameters

feature (Vector2Set) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ec (color) – Patch edge color. Default None

  • fc (color) – Patch face color. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

  • legend (bool) – Whether to show legend. Default False

  • weight (float) – Factor to scale probability density function Default 1

muci(*args, **kwargs)

Plot circular mean with bootstrapped confidence interval

Parameters

feature (Vector2Set) –

Keyword Arguments
  • alpha (scalar) – Set the alpha value. Default None

  • color (color) – Set the color of the point. Default None

  • ls (str) – Line style string (only for multiple features). Default “-”

  • lw (float) – Set line width. Default 1.5

  • confidence_level (float) – Confidence interval. Default 95

  • n_resamples (int) – Number of bootstrapped samples. Default 9999

class apsg.plotting.VollmerPlot(*args, **kwargs)

Bases: FabricPlot

Represents the triangular fabric plot (Vollmer, 1989).

Keyword Arguments
  • title (str) – figure title. Default None.

  • title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.

  • ticks (bool) – Show ticks. Default True

  • n_ticks (int) – Number of ticks. Default 10

  • tick_size (float) – Size of ticks. Default 0.2

  • margin (float) – Size of margin. Default 0.05

  • grid (bool) – Show grid. Default is True

  • grid_color (str) – Matplotlib color of the grid. Default “k”

  • grid_style (str) – Matplotlib style of the grid. Default “:”

Examples

>>> l = linset.random_fisher(position=lin(120, 40))
>>> ot = l.ortensor()
>>> s = VollmerPlot(title="Point distribution")
>>> s.point(ot)
>>> s.show()
point(*args, **kwargs)

Plot ellipsoid as point

path(*args, **kwargs)

Plot EllipsoidSet as path

class apsg.plotting.RamsayPlot(*args, **kwargs)

Bases: FabricPlot

Represents the Ramsay deformation plot.

Keyword Arguments
  • title (str) – figure title. Default None.

  • title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.

  • ticks (bool) – Show ticks. Default True

  • n_ticks (int) – Number of ticks. Default 10

  • tick_size (float) – Size of ticks. Default 0.2

  • margin (float) – Size of margin. Default 0.05

  • grid (bool) – Show grid. Default is True

  • grid_color (str) – Matplotlib color of the grid. Default “k”

  • grid_style (str) – Matplotlib style of the grid. Default “:”

Examples

>>> l = linset.random_fisher(position=lin(120, 40))
>>> ot = l.ortensor()
>>> s = RamsayPlot(title="Point distribution")
>>> s.point(ot)
>>> s.show()
point(*args, **kwargs)

Plot ellipsoid as point

path(*args, **kwargs)

Plot EllipsoidSet as path

class apsg.plotting.FlinnPlot(*args, **kwargs)

Bases: FabricPlot

Represents the Ramsay deformation plot.

Keyword Arguments
  • title (str) – figure title. Default None.

  • title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.

  • ticks (bool) – Show ticks. Default True

  • n_ticks (int) – Number of ticks. Default 10

  • tick_size (float) – Size of ticks. Default 0.2

  • margin (float) – Size of margin. Default 0.05

  • grid (bool) – Show grid. Default is True

  • grid_color (str) – Matplotlib color of the grid. Default “k”

  • grid_style (str) – Matplotlib style of the grid. Default “:”

Examples

>>> l = linset.random_fisher(position=lin(120, 40))
>>> ot = l.ortensor()
>>> s = FlinnPlot(title="Point distribution")
>>> s.point(ot)
>>> s.show()
point(*args, **kwargs)

Plot Ellipsoid as point

path(*args, **kwargs)

Plot EllipsoidSet as path

class apsg.plotting.HsuPlot(*args, **kwargs)

Bases: FabricPlot

Represents the Hsu fabric plot.

Keyword Arguments
  • title (str) – figure title. Default None.

  • title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.

  • ticks (bool) – Show ticks. Default True

  • n_ticks (int) – Number of ticks. Default 10

  • tick_size (float) – Size of ticks. Default 0.2

  • margin (float) – Size of margin. Default 0.05

  • grid (bool) – Show grid. Default is True

  • grid_color (str) – Matplotlib color of the grid. Default “k”

  • grid_style (str) – Matplotlib style of the grid. Default “:”

Examples

>>> l = linset.random_fisher(position=lin(120, 40))
>>> ot = l.ortensor()
>>> s = HsuPlot(title="Point distribution")
>>> s.point(ot)
>>> s.show()
point(*args, **kwargs)

Plot Ellipsoid as point

path(*args, **kwargs)

Plot EllipsoidSet as path

apsg.plotting.quicknet(*args, **kwargs)

Function to quickly show or save StereoNet from args

Parameters

args – object(s) to be plotted. Instaces of Vector3, Foliation, Lineation, Pair, Fault, Cone, Vector3Set, FoliationSet, LineationSet, PairSet or FaultSet.

Keyword Arguments
  • savefig (bool) – True to save figure. Default False

  • filename (str) – filename for figure. Default stereonet.png

  • savefig_kwargs (dict) – dict passed to plt.savefig

  • fol_as_pole (bool) – True to plot planar features as poles, False for plotting as great circle. Default True

Example

>>> l = linset.random_fisher(position=lin(120, 50))
>>> f = folset.random_fisher(position=lin(300, 40))
>>> quicknet(f, l, fol_as_pole=False)