2-Dimensional plotting functions

src.splotch.plots_2d.contour(z, x=None, y=None, filled=None, xlim=None, ylim=None, xinvert=False, yinvert=False, xlog=False, ylog=False, title=None, xlabel=None, ylabel=None, lab_loc=0, ax=None, grid=None, plot_kw={}, **kwargs)

Level contour plotting function.

This is a wrapper for pyplot.contour() and pyplot.contourf().

Parameters
  • z (array-like) – The height values to draw the contours.

  • x (array-like, optional) – Position of data points in the x axis.

  • y (array-like, optional) – Position of data points in the y axis.

  • filled (boolean, optional) – If True, draws filled contours. If not given defaults to the value defined in splotch.Params.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • xinvert (bool, optional) – If True, inverts the x-axis.

  • yinvert (bool, optional) – If True, inverts the y-axis.

  • xlog (bool, optional) – If True, the scale of the x-axis is logarithmic. If not given defaults to the value defined in splotch.Params.

  • ylog (bool, optional) – If True, the scale of the x-axis is logarithmic. If not given defaults to the value defined in splotch.Params.

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • output (boolean, optional) – If True, returns the edges and values of the underlying histogram plus the levels of the contours.

  • plot_kw (dict, optional) – Passes the given dictionary as a kwarg to the plotting function. Valid kwargs are QuadContourSet properties.

  • **kwargs (QuadContourSet properties, optional) – kwargs are used to specify matplotlib specific properties such as cmap, linewidths, hatches, etc. The list of available properties can be found here: https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.contour.html

Returns

  • bin_edges_x (array) – The bin edges for the x axis.

  • bin_edges_y (array) – The bin edges for the y axis.

  • n (array) – The values of the underlying histogram.

  • l (array) – The levels for the contours.

src.splotch.plots_2d.contourp(x, y, percent=None, filled=None, bin_type=None, bins=None, smooth=0.0, max_spacing=True, xlim=None, ylim=None, xinvert=False, yinvert=False, xlog=False, ylog=False, title=None, labels=None, xlabel=None, ylabel=None, lab_loc=0, ax=None, grid=None, output=None, plot_kw={}, **kwargs)

Contour function, encircling the highest density regions that contain the given percentages of the sample.

Parameters
  • x (array-like) – Position of data points in the x axis.

  • y (array-like) – Position of data points in the y axis.

  • percent (float or array-like, optional.) – The percentages of the sample for the contours to encircle.

  • bin_type ({‘number’, ‘width’, ‘edges’, ‘equal’}, optional) –

    Defines the format for the value(s) given in bins.
    • ‘number’ specifies the desired number of bins.

    • ‘width’ specifies the width of the bins.

    • ‘edges’ for the edges of bins

    • ‘equal’ results in bins with an equal number of elements (or as close as possible).

    If bin_type not given, it is inferred from the data type of bins, i.e., ‘number’ if int, ‘width’ if float and ‘edges’ if a list-like object.

  • bins (int, float, array-like, optional) – Specifies the value(s) for the bins, according to bin_type.

  • smooth (float, optional) – The standard deviation for the Gaussian kernel. Default: 0.0 (No smoothing).

  • max_spacing (boolean, optional) – If True, maximises the separation between colours drawn from the colour map. Default: True.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • xinvert (bool, optional) – If True, inverts the x-axis.

  • yinvert (bool, optional) – If True, inverts the y-axis.

  • xlog (bool, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool, optional) – If True, the scale of the x-axis is logarithmic.

  • title (str, optional) – Sets the title of the plot

  • labels (array-like or boolean, optional) – Specifies label(s) for the contour(s). If given as an array of strings, sets the labels for each contour. Must be of equal length to number specified by ‘percent’. If False, no legend is drawn.

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • output (boolean, optional) – If True, returns the edges and values of the underlying histogram in addition to the default output of.

  • plot_kw (dict, optional) – Passes the given dictionary as a kwarg to the plotting function. Valid kwargs are QuadContourSet properties.

  • **kwargs (QuadContourSet properties, optional) – kwargs are used to specify matplotlib specific properties such as cmap, linewidths, hatches, etc. The list of available properties can be found here: https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.contour.html

Returns

  • bin_edges_x (array) – The bin edges for the x axis.

  • bin_edges_y (array) – The bin edges for the y axis.

  • n (array) – The values of the underlying histogram.

  • l (array) – The levels for the contours.

src.splotch.plots_2d.errorband(x, y, yerr, line=False, xlim=None, ylim=None, xinvert=False, yinvert=False, xlog=False, ylog=None, title=None, xlabel=None, ylabel=None, label=None, lab_loc=0, ax=None, grid=None, line_kw={}, band_kw={}, **kwargs)

Error line and band plotting function.

Parameters
  • x (array-like or list) – If list it is assumed that each elemement is array-like.

  • y (array-like or list) – If list it is assumed that each elemement is array-like.

  • yerr (array-like or list, optional) – Defines the length of the errobars in the y-axis. If list it is assumed that each elemement is array-like.

  • line (boolean, optional) – If True, draw a line that follows the statistic defined in line_stat.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • xinvert (bool or list, optional) – If True, inverts the x-axis.

  • yinvert (bool or list, optional) – If True, inverts the y-axis.

  • xlog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • label (str, optional) – Sets the label for the plot.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • plot_kw (dict, optional) – Passes the given dictionary as a kwarg to the plotting function. Valid kwargs are Line2D properties.

  • **kwargs (Line2D properties, optional) – kwargs are used to specify matplotlib specific properties such as linecolor, linewidth, antialiasing, etc. A list of available Line2D properties can be found here: https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.Line2D.html#matplotlib.Line2D

Return type

None

src.splotch.plots_2d.errorbar(x, y, xerr=None, yerr=None, xlim=None, ylim=None, xinvert=False, yinvert=False, xlog=False, ylog=False, title=None, xlabel=None, ylabel=None, label=None, lab_loc=0, ax=None, grid=None, plot_kw={}, **kwargs)

Errorbar plotting function.

This is a wrapper for pyplot.errorbar().

Parameters
  • x (array-like or list) – If list it is assumed that each elemement is array-like.

  • y (array-like or list) – If list it is assumed that each elemement is array-like.

  • xerr (array-like or list, optional) – Defines the length of the errobars in the x-axis. If list it is assumed that each elemement is array-like.

  • yerr (array-like or list, optional) – Defines the length of the errobars in the y-axis. If list it is assumed that each elemement is array-like.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • xinvert (bool or list, optional) – If True, inverts the x-axis.

  • yinvert (bool or list, optional) – If True, inverts the y-axis.

  • xlog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • label (str, optional) – Sets the label for the plot.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • plot_kw (dict, optional) – Passes the given dictionary as a kwarg to the plotting function. Valid kwargs are Line2D properties.

  • **kwargs (Line2D properties, optional) – kwargs are used to specify matplotlib specific properties such as linecolor, linewidth, antialiasing, etc. A list of available Line2D properties can be found here: https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.Line2D.html#matplotlib.Line2D

Return type

None

src.splotch.plots_2d.errorbox(x, y, xerr=None, yerr=None, xlim=None, ylim=None, xinvert=False, yinvert=False, xlog=False, ylog=False, box_type='ellipse', title=None, xlabel=None, ylabel=None, label=None, grid=None, lab_loc=0, ax=None, plot_kw={}, **kwargs)

Errorbox plotting function.

This is a wrapper around matplotlib PatchCollections with a matplotlib errorbar functionality.

Parameters
  • x (array-like or list) – If list it is assumed that each elemement is array-like.

  • y (array-like or list) – If list it is assumed that each elemement is array-like.

  • xerr (array-like or list, optional) – Defines the length of the errobars in the x-axis. If list it is assumed that each elemement is array-like.

  • yerr (array-like or list, optional) – Defines the length of the errobars in the y-axis. If list it is assumed that each elemement is array-like.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • xinvert (bool or list, optional) – If True, inverts the x-axis.

  • yinvert (bool or list, optional) – If True, inverts the y-axis.

  • xlog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • box_type (str) – The type of box to plot, patch types include: ellipse | rectangle (Default: ellipse).

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • label (str, optional) – Sets the label for the plot.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • plot_kw (dict, optional) – Passes the given dictionary as a kwarg to the plotting function. Valid kwargs are Patches properties.

  • **kwargs (Patch properties, optional) – kwargs are used to specify matplotlib specific properties such as facecolor, linestyle, alpha, etc. A list of available Patch properties can be found here: https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.patches.Rectangle.html

Return type

None

src.splotch.plots_2d.hexbin(x, y, bins=None, binlims=None, dens=True, scale=None, c=None, cstat=None, xlim=None, ylim=None, clim=[None, None], nmin=0, xinvert=False, yinvert=False, cbar_invert=False, xlog=False, ylog=False, clog=None, title=None, xlabel=None, ylabel=None, clabel=None, lab_loc=0, ax=None, grid=None, output=None, plot_kw={}, **kwargs)

Hexagonal 2D bins function.

Parameters
  • x (array-like) – Position of data points in the x axis.

  • y (array-like) – Position of data points in the y axis.

  • bins (int or list, optional) – Gives the number of bins

  • binlims (array-like, optional) – Defines the limits for the bin range, given as a one-dimensional list containing four elements (left, right, bottom, top). Note, if xlog=True or ylog=True, then the values of binlim must also be logged. The default assigns the limits based on gridsize, x, y, xscale and yscale.

  • dens (bool or list, optional) – If false the histogram returns raw counts.

  • c (array-like, optional) – If a valid argument is given in cstat, defines the value used for the binned statistics.

  • cstat (str or function, optional) – Must be one of the valid str arguments for the statistics variable in scipy.stats.binned_statistic_2d (‘mean’, ‘median’, ‘count’, ‘sum’, ‘min’ or ‘max’) or a function that takes a 1D array and outputs an integer or float.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • clim (list, optional) – Defines the limits of the colour map ranges, it must contain two elements (lower and higer limits).

  • nmin (int, optional (default: 0)) – The minimum number of points required in a bin in order to be plotted.

  • xinvert (bool, optional) – If True, inverts the x-axis.

  • yinvert (bool, optional) – If True, inverts the y-axis.

  • cbar_invert (bool, optional) – If True, inverts the direction of the colour bar (not the colour map).

  • xlog (bool, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool, optional) – If True, the scale of the x-axis is logarithmic.

  • clog (bool, optional) – If True, the colour map is changed from linear to logarithmic.

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • clabel (str, optional) – Setting clabel triggers the generation of a colourbar with axis label given by its value.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • output (boolean, optional) – If True, returns the edges and values of the histogram.

  • plot_kw (dict, optional) – Explicit dictionary of kwargs to be parsed to matplotlib hexbin function. Parameters will be overwritten if also given implicitly as a **kwarg.

  • **kwargs (pcolormesh properties, optional) – kwargs are used to specify matplotlib specific properties such as cmap, norm, edgecolors etc. https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hexbin.html

Returns

  • n (array) – The values of the histogram. Only provided if output is True.

  • x_edges (array) – The bin edges for the x axis. Only provided if output is True.

  • y_edges (array) – The bin edges for the y axis. Only provided if output is True.

src.splotch.plots_2d.hist2D(x, y, weights=None, bins=None, bin_type=None, dens=True, scale=None, c=None, cstat=None, xlim=None, ylim=None, clim=[None, None], nmin=0, xinvert=False, yinvert=False, cbar_invert=False, xlog=False, ylog=False, clog=None, title=None, xlabel=None, ylabel=None, clabel=None, lab_loc=0, ax=None, grid=None, output=None, plot_kw={}, **kwargs)

2D histogram function.

Parameters
  • x (array-like) – Position of data points in the x axis.

  • y (array-like) – Position of data points in the y axis.

  • bin_type ({‘number’,’width’,’edges’,’equal’}, optional) – Defines how is understood the value given in bins: ‘number’ for givinf the desired number of bins, ‘width’ for the width of the bins, ‘edges’ for the edges of bins, and ‘equal’ for making bins with equal number of elements (or as close as possible). If not given it is inferred from the data type of bins: ‘number’ if int, ‘width’ if float and ‘edges’ if ndarray.

  • bins (int, float, array-like or list, optional) – Gives the values for the bins, according to bin_type.

  • dens (bool or list, optional) – If false the histogram returns raw counts.

  • scale (float or list, optional) – Scaling of the data counts.

  • c (array-like, optional) – If a valid argument is given in cstat, defines the value used for the binned statistics.

  • cstat (str or function, optional) – Must be one of the valid str arguments for the statistics variable in scipy.stats.binned_statistic_2d (‘mean’, ‘median’, ‘count’, ‘sum’, ‘min’ or ‘max’) or a function that takes a 1D array and outputs an integer or float.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • clim (list, optional) – Defines the limits of the colour map ranges, it must contain two elements (lower and higer limits).

  • nmin (int, optional (default: 0)) – The minimum number of points required in a bin in order to be plotted.

  • xinvert (bool, optional) – If True, inverts the x-axis.

  • yinvert (bool, optional) – If True, inverts the y-axis.

  • cbar_invert (bool, optional) – If True, inverts the direction of the colour bar (not the colour map).

  • xlog (bool, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool, optional) – If True, the scale of the x-axis is logarithmic.

  • clog (bool, optional) – If True, the colour map is changed from linear to logarithmic.

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • clabel (str, optional) – Setting clabel triggers the generation of a colourbar with axis label given by its value.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • output (boolean, optional) – If True, returns the edges and values of the histogram.

  • plot_kw (dict, optional) – Explicit dictionary of kwargs to be parsed to matplotlib pcolormesh function. Parameters will be overwritten if also given implicitly as a **kwarg.

  • **kwargs (pcolormesh properties, optional) – kwargs are used to specify matplotlib specific properties such as cmap, norm, edgecolors etc. https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pcolormesh.html

Returns

  • n (array) – The values of the histogram. Only provided if output is True.

  • x_edges (array) – The bin edges for the x axis. Only provided if output is True.

  • y_edges (array) – The bin edges for the y axis. Only provided if output is True.

src.splotch.plots_2d.img(im, x=None, y=None, xlim=None, ylim=None, clim=[None, None], cmin=0, xinvert=False, yinvert=False, cbar_invert=False, clog=None, title=None, xlabel=None, ylabel=None, clabel=None, lab_loc=0, ax=None, grid=None, plot_kw={}, **kwargs)

2D pixel-based image plotting function.

Parameters
  • im (array-like) – Value for each pixel in an x-y 2D array, where the first dimension is the x-position and the second is the y-position.

  • x (array-like, optional) – Position of data points in the x axis.

  • y (array-like, optional) – Position of data points in the y axis.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • clim (list, optional) – Defines the limits of the colour map ranges, it must contain two elements (lower and higer limits).

  • clog (bool, optional) – If True, the colour map is changed from linear to logarithmic.

  • xinvert (bool, optional) – If True, inverts the x-axis.

  • yinvert (bool, optional) – If True, inverts the y-axis.

  • cbar_invert (bool, optional) – If True, inverts the direction of the colour bar (not the colour map).

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • clabel (str, optional) – Setting clabel triggers the generation of a colourbar with axis label given by its value.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • plot_kw (dict, optional) – Explicit dictionary of kwargs to be parsed to matplotlib pcolormesh function. Parameters will be overwritten if also given implicitly as a **kwarg.

  • **kwargs (pcolormesh properties, optional) – kwargs are used to specify matplotlib specific properties such as cmap, marker, norm, etc. A list of available pcolormesh properties can be found here: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pcolormesh.html

Return type

None

src.splotch.plots_2d.scatter(x, y, c=None, xlim=None, ylim=None, clim=None, density=False, xinvert=False, yinvert=False, cbar_invert=False, xlog=False, ylog=False, title=None, xlabel=None, ylabel=None, clabel=None, label=None, lab_loc=0, ax=None, grid=None, plot_kw={}, **kwargs)

2D pixel-based image plotting function.

Parameters
  • x (array-like or list) – Position of data points in the x-axis.

  • y (array-like or list) – Position of data points in the y-axis.

  • c (array-like or list or str, optional) – Value of data points in the z-axis (colour-axis).

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • clim (tuple-like, optional) – Defines the limits of the colour-axis, it must contain two elements (lower and higer limits). Functions equivalently to the vmin, vmax arguments used by colors.Normalize. If both are given, clim takes priority.

  • density (bool, optional) – If True, color-codes points by their spatial density to nearby points using a Gaussian kernel density estimate. If ‘c’ also given, ‘density’ takes precedence. Default: False.

  • xinvert (bool, optional) – If True, inverts the x-axis.

  • yinvert (bool, optional) – If True, inverts the y-axis.

  • cbar_invert (bool, optional) – If True, inverts the direction of the colour bar (not the colour map).

  • xlog (bool, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool, optional) – If True, the scale of the x-axis is logarithmic.

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • clabel (str, optional) – Setting clabel triggers the generation of a colourbar with axis label given by its value.

  • label (str, optional) – Sets the label for the scatter plot.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • plot_kw (dict, optional) – Explicit dictionary of kwargs to be parsed to matplotlib scatter function. Parameters will be overwritten if also given implicitly as a **kwarg.

  • **kwargs (Collection properties, optional) – kwargs are used to specify matplotlib specific properties such as cmap, marker, norm, etc. A list of available Collection properties can be found here: https://matplotlib.org/api/collections_api.html#matplotlib.collections.Collection

Returns

A list of PathCollection objects representing the plotted data.

Return type

paths

src.splotch.plots_2d.sector(r, theta, rlim=(0.0, 1.0), thetalim=(0.0, 360.0), clim=None, rotate=0.0, rlabel='', thetalabel='', clabel=None, label=None, rstep=None, thetastep=15.0, rticks='auto', thetaticks='auto', cbar_invert=False, fig=None, plot_kw={}, **kwargs)

Sector Plot function

Plots a sector plot (a.k.a “pizza plot”) based on data with one radial axis and an angular axis

Parameters
  • r (array-like or list) – Radial axis data.

  • theta (array-like or list) – Angular axis data (degrees).

  • rlim (tuple-like, optional) – The lower and upper limits for the radial axis (degrees).

  • thetalim (tuple-like, optional) – The lower and upper limits for the angular axis (degrees).

  • clim (tuple-like, optional) – Defines the limits of the colour-axis, it must contain two elements (lower and higer limits). Functions equivalently to the vmin, vmax arguments used by colors.Normalize. If both are given, clim takes priority.

  • rotate (float, optional) – By how many degrees (clockwise) to rotate the entire plot (valid values in [-180, 180]).

  • rlabel (str, optional) – Sets the label of the r-axis.

  • thetalabel (str, optional) – Sets the label of the theta-axis.

  • clabel (str, optional) – Setting clabel triggers the generation of a colourbar with axis label given by its value.

  • label (str, optional) – Sets the label for the scatter plot.

  • rstep (float, optional) – Sets the step size of r ticks.

  • thetastep (float, optional, default: 15.0) – Sets the step size of theta ticks (degrees).

  • rticks (‘auto’, or ticker) –

    • Not implement *

  • thetaticks (‘auto’, or ticker) –

    • Not implement *

  • cbar_invert (bool, optional) – If True, inverts the direction of the colour bar (not the colour map).

  • fig (pyplot.Figure, optional) – Use the given figure to make the plot, defaults to the current figure.

  • plot_kw (dict, optional) – Explicit dictionary of kwargs to be parsed to matplotlib scatter function. Parameters will be overwritten if also given implicitly in **kwargs.

  • **kwargs (Collection properties, optional) – kwargs are used to specify matplotlib specific properties such as cmap, marker, norm, etc. A list of available Collection properties can be found here: https://matplotlib.org/3.1.0/api/collections_api.html#matplotlib.collections.Collection

Returns

ax

Return type

The pyplot.Axes object created for the sector plot.

src.splotch.plots_2d.statband(x, y, bin_type=None, bins=None, stat_mid='mean', stat_low='std', stat_high='std', from_mid=None, line=False, xlim=None, ylim=None, xinvert=False, yinvert=False, xlog=False, ylog=None, nmin=0, title=None, xlabel=None, ylabel=None, label=None, lab_loc=0, ax=None, grid=None, line_kw={}, band_kw={}, **kwargs)

Statistics line and band plotting function.

Parameters
  • x (array-like or list) – If list it is assumed that each elemement is array-like.

  • y (array-like or list) – If list it is assumed that each elemement is array-like.

  • bin_type ({‘number’,’width’,’edges’,’equal’}, optional) – Defines how is understood the value given in bins: ‘number’ for the desired number of bins, ‘width’ for the width of the bins, ‘edges’ for the edges of bins, and ‘equal’ for making bins with equal number of elements (or as close as possible). If not given it is inferred from the data type of bins: ‘number’ if int, ‘width’ if float and ‘edges’ if ndarray.

  • bins (int, float, array-like or list, optional) – Gives the values for the bins, according to bin_type.

  • stat_mid (str, int, float or function, optional) – Defines how to calculate the midpoint of the statistics band. When passing a string it must be either one of the options for scipy.binned_statistic(), i.e. ‘mean’, ‘std’, ‘median’, ‘count’, ‘sum’, ‘min’, ‘max’ or a user-defined function. If given as an integer or float, the number represents the value for the percentile to calculate in each bin. A function can be given which takes (only) a 1D array of values and returns a numerical statistic.

  • stat_low / stat_high (str, int, float or function, optional) – Defines how to calculate the lower/upper limits for the statistic band. Can be given as one of the recognised strings above or as a string combining ‘std’ with a number, i.e. ‘[n]std’, where [n] is the number of standard deviations away from the line of stat_mid. Can also be given as a number (integer or float) or function as described for stat_mid.

  • from_mid (boolean, optional) – If True, the lower/upper bounds of the band are determined as the separation from the stat_mid line: i.e. stat_mid +/- stat_[low/high], otherwise, they are set to the values returned by stat_[low/high]. Defaults to True if stat_[low/high] are standard deviations.

  • line (boolean, optional) – If True, draw a line that follows the statistic defined in line_stat.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • xinvert (bool or list, optional) – If True, inverts the x-axis.

  • yinvert (bool or list, optional) – If True, inverts the y-axis.

  • xlog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • nmin (int, optional (default: 0)) – The minimum number of points required in a bin in order to be plotted.

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • label (str, optional) – Sets the label for the plot.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, optional) – If not given defaults to the value defined in splotch.Params.

  • band_kw (dict, optional) – Passes the given dictionary as a kwarg to the plotting function. Valid kwargs are Line2D properties.

  • **kwargs (Line2D properties, optional) – kwargs are used to specify matplotlib specific properties such as linecolor, linewidth, antialiasing, etc. A list of available Line2D properties can be found here: https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.Line2D.html#matplotlib.Line2D

Return type

None

src.splotch.plots_2d.statbar(x, y, bin_type=None, bins=None, stat_cen='mean', bar_x=True, stat_y='std', mask_na=False, line=False, xlim=None, ylim=None, xinvert=False, yinvert=False, xlog=False, ylog=None, title=None, xlabel=None, ylabel=None, label=None, lab_loc=0, ax=None, grid=None, plot_kw={}, **kwargs)

Statistics line and bar plotting function.

Parameters
  • x (array-like or list) – If list it is assumed that each elemement is array-like.

  • y (array-like or list) – If list it is assumed that each elemement is array-like.

  • bin_type ({‘number’,’width’,’edges’,’equal’}, optional) – Defines how is understood the value given in bins: ‘number’ for the desired number of bins, ‘width’ for the width of the bins, ‘edges’ for the edges of bins, and ‘equal’ for making bins with equal number of elements (or as close as possible). If not given it is inferred from the data type of bins: ‘number’ if int, ‘width’ if float and ‘edges’ if ndarray.

  • bins (int, float, array-like or list, optional) – Gives the values for the bins, according to bin_type.

  • stat_cen (str, int, float, function, or 2-element array-like of any of the previous type, optional) – Defines how to calculate the position of centre of each errorbar. When passing an integer or float is interpreted as being the percentile for the limit. When passing a function it must have the input and ouput characteristics required by scipy.binned_statistic().

  • bar_x (bool, optional) – If False turns off the display of the bin widths with bars.

  • stat_y (str, int, float, function, or 2-element array-like of any of the previous type, optional) – Defines how to calculate the y error bars. When passing a string it must be either one of the options for scipy.binned_statistic(), or a string that combines ‘std’ with a number (e.g., ‘2.2std’), where to number is interpreted as the number of standard deviations that the limit must cover. When passing an integer or float is interpreted as being the percentile for the limit. When passing a function it must have the input and ouput characteristics required by scipy.stats.binned_statistic().

  • mask_na (bool, optional (default: False)) – Whether to mask empty values (NA, NaN) in an array before calculating the statistic.

  • line (boolean, optional) – If True, draw a line that follows the statistic defined in line_stat.

  • xlim (tuple-like, optional) – Defines the limits of the x-axis, it must contain two elements (lower and higer limits).

  • ylim (tuple-like, optional) – Defines the limits of the y-axis, it must contain two elements (lower and higer limits).

  • xinvert (bool or list, optional) – If True, inverts the x-axis.

  • yinvert (bool or list, optional) – If True, inverts the y-axis.

  • xlog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • ylog (bool or list, optional) – If True, the scale of the x-axis is logarithmic.

  • title (str, optional) – Sets the title of the plot

  • xlabel (str, optional) – Sets the label of the x-axis.

  • ylabel (str, optional) – Sets the label of the y-axis.

  • label (str, optional) – Sets the label for the plot.

  • lab_loc (int, optional) – Defines the position of the legend

  • ax (pyplot.Axes, optional) – Use the given axes to make the plot, defaults to the current axes.

  • grid (boolean, dict or None) –

    The grid behaviour, acts according to:
    • If boolean, the grid is set on (True) or off (False).

    • If dict, allows specific .Line2D properties of the grid to be set.

    • If None, use default grid parameters if this is the initial plotting call, otherwise do nothing.

  • plot_kw (dict, optional) – Passes the given dictionary as a kwarg to the plotting function. Valid kwargs are Line2D properties.

  • **kwargs (Line2D properties, optional) – kwargs are used to specify matplotlib specific properties such as linecolor, linewidth, antialiasing, etc. A list of available Line2D properties can be found here: https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.Line2D.html#matplotlib.Line2D

Return type

None