pyrolite.plot.pyroplot (Pandas Interface)

class pyrolite.plot.pyroplot(obj)[source]
cooccurence(ax=None, normalize=True, log=False, colorbar=False, **kwargs)[source]

Plot the co-occurence frequency matrix for a given input.

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

  • normalize (bool) – Whether to normalize the cooccurence to compare disparate variables.

  • log (bool) – Whether to take the log of the cooccurence.

  • colorbar (bool) – Whether to append a colorbar.

Returns

Axes on which the cooccurence plot is added.

Return type

matplotlib.axes.Axes

density(components: Optional[list] = None, ax=None, axlabels=True, **kwargs)[source]

Method for plotting histograms (mode=’hist2d’|’hexbin’) or kernel density esitimates from point data. Convenience access function to density() (see Other Parameters, below), where further parameters for relevant matplotlib functions are also listed.

Parameters
  • components (list, None) – Elements or compositional components to plot.

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

  • axlabels (bool, True) – Whether to add x-y axis labels.

Note

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

Other Parameters
  • arr (numpy.ndarray) – Dataframe from which to draw data.

  • logx (bool, False) – Whether to use a logspaced grid on the x axis. Values strictly >0 required.

  • logy (bool, False) – Whether to use a logspaced grid on the y axis. Values strictly >0 required.

  • bins (int, 20) – Number of bins used in the gridded functions (histograms, KDE evaluation grid).

  • mode (str, ‘density’) – Different modes used here: [‘density’, ‘hexbin’, ‘hist2d’]

  • extent (list) – Predetermined extent of the grid for which to from the histogram/KDE. In the general form (xmin, xmax, ymin, ymax).

  • contours (list) – Contours to add to the plot, where mode='density' is used.

  • percentiles (bool, True) – Whether contours specified are to be converted to percentiles.

  • relim (bool, True) – Whether to relimit the plot based on xmin, xmax values.

  • cmap (matplotlib.colors.Colormap) – Colormap for mapping surfaces.

  • vmin (float, 0.) – Minimum value for colormap.

  • shading (str, ‘auto’) – Shading to apply to pcolormesh.

  • colorbar (bool, False) – Whether to append a linked colorbar to the generated mappable image.

Returns

Axes on which the density diagram is plotted.

Return type

matplotlib.axes.Axes

heatscatter(components: Optional[list] = None, ax=None, axlabels=True, logx=False, logy=False, **kwargs)[source]

Heatmapped scatter plots using the pyroplot API. See further parameters for matplotlib.pyplot.scatter function below.

Parameters
  • components (list, None) – Elements or compositional components to plot.

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

  • axlabels (bool, True) – Whether to add x-y axis labels.

  • logx (bool, False) – Whether to log-transform x values before the KDE for bivariate plots.

  • logy (bool, False) – Whether to log-transform y values before the KDE for bivariate plots.

Returns

Axes on which the heatmapped scatterplot is added.

Return type

matplotlib.axes.Axes

parallel(components=None, rescale=False, legend=False, ax=None, **kwargs)[source]

Create a pyrolite.plot.parallel.parallel(). coordinate plot from the columns of the DataFrame.

Parameters
  • components (list, None) – Components to use as axes for the plot.

  • rescale (bool) – Whether to rescale values to [-1, 1].

  • legend (bool, False) – Whether to include or suppress the legend.

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

Note

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

Other Parameters

df (pandas.DataFrame) – Dataframe to create a plot from.

Returns

Axes on which the parallel coordinates plot is added.

Return type

matplotlib.axes.Axes

Todo

  • Adapt figure size based on number of columns.

plot(components: Optional[list] = None, ax=None, axlabels=True, **kwargs)[source]

Convenience method for line plots using the pyroplot API. See further parameters for matplotlib.pyplot.scatter function below.

Parameters
  • components (list, None) – Elements or compositional components to plot.

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

  • axlabels (bool, True) – Whether to add x-y axis labels.

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 plot is added.

Return type

matplotlib.axes.Axes

REE(index='elements', ax=None, mode='plot', dropPm=True, scatter_kw={}, line_kw={}, **kwargs)[source]

Pass the pandas object to pyrolite.plot.spider.REE_v_radii().

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

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

  • mode (str, :code`[“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.

  • dropPm (bool) – Whether to exclude the (almost) non-existent element Promethium from the REE list.

  • 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.

Note

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

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

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

  • 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.

  • 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.

Returns

Axes on which the REE plot is added.

Return type

matplotlib.axes.Axes

scatter(components: Optional[list] = None, ax=None, axlabels=True, **kwargs)[source]

Convenience method for scatter plots using the pyroplot API. See further parameters for matplotlib.pyplot.scatter function below.

Parameters
  • components (list, None) – Elements or compositional components to plot.

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

  • axlabels (bool, True) – Whether to add x-y axis labels.

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).

Returns

Axes on which the scatterplot is added.

Return type

matplotlib.axes.Axes

spider(components: Optional[list] = None, indexes: Optional[list] = None, ax=None, mode='plot', index_order=None, autoscale=True, scatter_kw={}, line_kw={}, **kwargs)[source]

Method for spider plots. Convenience access function to spider() (see Other Parameters, below), where further parameters for relevant matplotlib functions are also listed.

Parameters
  • components (list, None) – Elements or compositional components to plot.

  • indexes (list, None) – Elements or compositional components to plot.

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

  • index_order – Function to order spider plot indexes (e.g. by incompatibility).

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

  • mode (str, :code`[“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.

  • 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.

Note

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

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

  • 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.

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

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

Returns

Axes on which the spider diagram is plotted.

Return type

matplotlib.axes.Axes

Todo

  • Add ‘compositional data’ filter for default components if None is given

stem(components: Optional[list] = None, ax=None, orientation='horizontal', axlabels=True, **kwargs)[source]

Method for creating stem plots. Convenience access function to stem() (see Other Parameters, below), where further parameters for relevant matplotlib functions are also listed.

Parameters
  • components (list, None) – Elements or compositional components to plot.

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

  • orientation (str) – Orientation of the plot (horizontal or vertical).

  • axlabels (bool, True) – Whether to add x-y axis labels.

Note

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

Other Parameters

x, y (numpy.ndarray) – 1D arrays for independent and dependent axes.

Returns

Axes on which the stem diagram is plotted.

Return type

matplotlib.axes.Axes