pyrolite.plot.spider

pyrolite.plot.spider.spider(arr, indexes=None, ax=None, label=None, logy=True, yextent=None, mode='plot', unity_line=False, scatter_kw={}, line_kw={}, set_ticks=True, autoscale=True, **kwargs)[source]

Plots spidergrams for trace elements data. Additional arguments are typically forwarded to respective matplotlib functions plot() and scatter() (see Other Parameters, below).

Parameters
  • arr (numpy.ndarray) – Data array.

  • indexes (: numpy.ndarray) – Numerical indexes of x-axis positions.

  • ax (matplotlib.axes.Axes, None) – The subplot to draw on.

  • label (str, None) – Label for the individual series.

  • logy (bool) – Whether to use a log y-axis.

  • yextent (tuple) – Extent in the y direction for conditional probability plots, to limit the gridspace over which the kernel density estimates are evaluated.

  • mode (str, ["plot", "fill", "binkde", "ckde", "kde", "hist"]) – Mode for plot. Plot will produce a line-scatter diagram. Fill will return a filled range. Density will return a conditional density diagram.

  • unity_line (bool) – Add a line at y=1 for reference.

  • scatter_kw (dict) – Keyword parameters to be passed to the scatter plotting function.

  • line_kw (dict) – Keyword parameters to be passed to the line plotting function.

  • set_ticks (bool) – Whether to set the x-axis ticks according to the specified index.

  • autoscale (bool) – Whether to autoscale the y-axis limits for standard spider plots.

Note

The following additional parameters are from matplotlib.pyplot.scatter().

Other Parameters
  • x, y (float or array-like, shape (n, )) – The data positions.

  • s (float or array-like, shape (n, ), optional) – The marker size in points**2 (typographic points are 1/72 in.). Default is rcParams['lines.markersize'] ** 2.

    The linewidth and edgecolor can visually interact with the marker size, and can lead to artifacts if the marker size is smaller than the linewidth.

    If the linewidth is greater than 0 and the edgecolor is anything but ‘none’, then the effective size of the marker will be increased by half the linewidth because the stroke will be centered on the edge of the shape.

    To eliminate the marker edge either set linewidth=0 or edgecolor=’none’.

  • c (array-like or list of colors or color, optional) – The marker colors. Possible values:

    • A scalar or sequence of n numbers to be mapped to colors using cmap and norm.

    • A 2D array in which the rows are RGB or RGBA.

    • A sequence of colors of length n.

    • A single color format string.

    Note that c should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. If you want to specify the same RGB or RGBA value for all points, use a 2D array with a single row. Otherwise, value-matching will have precedence in case of a size matching with x and y.

    If you wish to specify a single color for all points prefer the color keyword argument.

    Defaults to None. In that case the marker color is determined by the value of color, facecolor or facecolors. In case those are not specified or None, the marker color is determined by the next color of the Axes’ current “shape and fill” color cycle. This cycle defaults to rcParams["axes.prop_cycle"].

  • marker (~.markers.MarkerStyle, default: rcParams["scatter.marker"]) – The marker style. marker can be either an instance of the class or the text shorthand for a particular marker. See matplotlib.markers for more information about marker styles.

  • cmap (str or ~matplotlib.colors.Colormap, default: rcParams["image.cmap"]) – The Colormap instance or registered colormap name used to map scalar data to colors.

    This parameter is ignored if c is RGB(A).

  • norm (str or ~matplotlib.colors.Normalize, optional) – The normalization method used to scale scalar data to the [0, 1] range before mapping to colors using cmap. By default, a linear scaling is used, mapping the lowest value to 0 and the highest to 1.

    If given, this can be one of the following:

    • An instance of .Normalize or one of its subclasses (see Colormap normalization).

    • A scale name, i.e. one of “linear”, “log”, “symlog”, “logit”, etc. For a list of available scales, call matplotlib.scale.get_scale_names(). In that case, a suitable .Normalize subclass is dynamically generated and instantiated.

    This parameter is ignored if c is RGB(A).

  • vmin, vmax (float, optional) – When using scalar data and no explicit norm, vmin and vmax define the data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data. It is an error to use vmin/vmax when a norm instance is given (but using a str norm name together with vmin/vmax is acceptable).

    This parameter is ignored if c is RGB(A).

  • alpha (float, default: None) – The alpha blending value, between 0 (transparent) and 1 (opaque).

  • linewidths (float or array-like, default: rcParams["lines.linewidth"]) – The linewidth of the marker edges. Note: The default edgecolors is ‘face’. You may want to change this as well.

  • edgecolors ({‘face’, ‘none’, None} or color or sequence of color, default: rcParams["scatter.edgecolors"]) – The edge color of the marker. Possible values:

    • ‘face’: The edge color will always be the same as the face color.

    • ‘none’: No patch boundary will be drawn.

    • A color or sequence of colors.

    For non-filled markers, edgecolors is ignored. Instead, the color is determined like with ‘face’, i.e. from c, colors, or facecolors.

  • plotnonfinite (bool, default: False) – Whether to plot points with nonfinite c (i.e. inf, -inf or nan). If True the points are drawn with the bad colormap color (see .Colormap.set_bad).

Note

The following additional parameters are from matplotlib.pyplot.plot().

Other Parameters
  • x, y (array-like or scalar) – The horizontal / vertical coordinates of the data points. x values are optional and default to range(len(y)).

    Commonly, these parameters are 1D arrays.

    They can also be scalars, or two-dimensional (in that case, the columns represent separate data sets).

    These arguments cannot be passed as keywords.

  • fmt (str, optional) – A format string, e.g. ‘ro’ for red circles. See the Notes section for a full description of the format strings.

    Format strings are just an abbreviation for quickly setting basic line properties. All of these and more can also be controlled by keyword arguments.

    This argument cannot be passed as keyword.

  • data (indexable object, optional) – An object with labelled data. If given, provide the label names to plot in x and y.

    Note

    Technically there’s a slight ambiguity in calls where the second label is a valid fmt. plot('n', 'o', data=obj) could be plt(x, y) or plt(y, fmt). In such cases, the former interpretation is chosen, but a warning is issued. You may suppress the warning by adding an empty format string plot('n', 'o', '', data=obj).

Returns

Axes on which the spiderplot is plotted.

Return type

matplotlib.axes.Axes

Notes

By using separate lines and scatterplots, values between two missing items are still presented.

Todo

  • Might be able to speed up lines with ~matplotlib.collections.LineCollection.

  • Legend entries

pyrolite.plot.spider.REE_v_radii(arr=None, ax=None, ree=['La', 'Ce', 'Pr', 'Nd', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu'], index='elements', mode='plot', logy=True, tl_rotation=60, unity_line=False, scatter_kw={}, line_kw={}, set_labels=True, set_ticks=True, **kwargs)[source]

Creates an axis for a REE diagram with ionic radii along the x axis.

Parameters
  • arr (numpy.ndarray) – Data array.

  • ax (matplotlib.axes.Axes, None) – Optional designation of axes to reconfigure.

  • ree (list) – List of REE to use as an index.

  • index (str) – Whether to plot using radii on the x-axis (‘radii’), or elements (‘elements’).

  • mode (str, ["plot", "fill", "binkde", "ckde", "kde", "hist"]) – Mode for plot. Plot will produce a line-scatter diagram. Fill will return a filled range. Density will return a conditional density diagram.

  • logy (bool) – Whether to use a log y-axis.

  • tl_rotation (float) – Rotation of the numerical index labels in degrees.

  • unity_line (bool) – Add a line at y=1 for reference.

  • scatter_kw (dict) – Keyword parameters to be passed to the scatter plotting function.

  • line_kw (dict) – Keyword parameters to be passed to the line plotting function.

  • set_labels (bool) – Whether to set the x-axis ticklabels for the REE.

  • set_ticks (bool) – Whether to set the x-axis ticks according to the specified index.

Note

The following additional parameters are from pyrolite.plot.spider.spider().

Other Parameters
  • indexes (: numpy.ndarray) – Numerical indexes of x-axis positions.

  • label (str, None) – Label for the individual series.

  • yextent (tuple) – Extent in the y direction for conditional probability plots, to limit the gridspace over which the kernel density estimates are evaluated.

  • autoscale (bool) – Whether to autoscale the y-axis limits for standard spider plots.

Returns

Axes on which the REE_v_radii plot is added.

Return type

matplotlib.axes.Axes

Todo

  • Turn this into a plot template within pyrolite.plot.templates submodule