plotting

geobipy.src.base.plotting.bar(values, edges, line=None, **kwargs)

Plot a bar chart.

Parameters:
  • values (array_like or StatArray) – Bar values

  • edges (array_like or StatArray) – edges of the bars

Returns:

matplotlib .Axes

Return type:

ax

See also

matplotlib.pyplot.hist

For additional keyword arguments you may use.

geobipy.src.base.plotting.clabel(cb, label, length=20, wrap=False, **kwargs)

Create a colourbar label with default fontsizes

Parameters:
  • cb (matplotlib.colorbar.Colorbar) – A colourbar to label

  • label (str) – The colourbar label

geobipy.src.base.plotting.generate_subplots(n, ax=None)

Generates subplots depending on whats given

Parameters:
  • n (int) – number of subplots

  • ax (variable, optional) – List of subplots. gridspec.GridSpec or gridspec.Subplotspec list of gridspec.Subplotspec Defaults to None.

geobipy.src.base.plotting.hillshade(arr, azimuth=30, altitude=30)

Create hillshade from a numpy array containing elevation data.

Taken from https://github.com/royalosyin/Work-with-DEM-data-using-Python-from-Simple-to-Complicated/blob/master/ex07-Hillshade%20from%20a%20Digital%20Elevation%20Model%20(DEM).ipynb

Parameters:
  • arr (numpy array of shape (rows, columns)) – Numpy array containing elevation values to be used to created hillshade.

  • azimuth (float (default=30)) – The desired azimuth for the hillshade.

  • altitude (float (default=30)) – The desired sun angle altitude for the hillshade.

Returns:

A numpy array containing hillshade values.

Return type:

numpy array

geobipy.src.base.plotting.hlines(*args, **kwargs)

Plot y against x

If x and y are StatArrays, the axes are automatically labelled.

Parameters:
  • x (array_like or StatArray) – The abcissa

  • y (array_like or StatArray) – The ordinate, can be upto 2 dimensions.

  • log ('e' or float, optional) – Take the log of the colour to a base. ‘e’ if log = ‘e’, and a number e.g. log = 10. Values in c that are <= 0 are masked.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’.

  • flipX (bool, optional) – Flip the X axis

  • flipY (bool, optional) – Flip the Y axis

  • labels (bool, optional) – Plot the labels? Default is True.

Returns:

matplotlib.Axes

Return type:

ax

See also

matplotlib.pyplot.plot

For additional keyword arguments you may use.

geobipy.src.base.plotting.make_colourmap(seq, cname)

Generate a Linear Segmented colourmap

Generates a colourmap from the sequence given and registers the colourmap with matplotlib.

Parameters:
  • seq (array of hex colours.) – e.g. [‘#000000’,’#00fcfd’,…]

  • cname (str) – Name of the colourmap.

Returns:

matplotlib.colors.LinearSegmentedColormap.

Return type:

out

geobipy.src.base.plotting.pause(interval)

Custom pause command to override matplotlib.pyplot.pause which keeps the figure on top of all others when using interactve mode.

Parameters:

interval (float) – Pause for interval seconds.

geobipy.src.base.plotting.pcolor(values, x=None, y=None, **kwargs)

Create a pseudocolour plot of a 2D array, Actually uses pcolormesh for speed.

Create a colour plot of a 2D array. If the arrays x, y, and values are geobipy.StatArray classes, the axes can be automatically labelled. Can take any other matplotlib arguments and keyword arguments e.g. cmap etc.

Parameters:
  • values (array_like or StatArray) – A 2D array of colour values.

  • x (1D array_like or StatArray, optional) – Horizontal coordinates of the values edges.

  • y (1D array_like or StatArray, optional) – Vertical coordinates of the values edges.

  • alpha (scalar or array_like, optional) – If alpha is scalar, behaves like standard matplotlib alpha and opacity is applied to entire plot If array_like, each pixel is given an individual alpha value.

  • log ('e' or float, optional) – Take the log of the colour to a base. ‘e’ if log = ‘e’, and a number e.g. log = 10. Values in c that are <= 0 are masked.

  • equalize (bool, optional) – Equalize the histogram of the colourmap so that all colours have an equal amount.

  • nbins (int, optional) – Number of bins to use for histogram equalization.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’

  • flipX (bool, optional) – Flip the X axis

  • flipY (bool, optional) – Flip the Y axis

  • grid (bool, optional) – Plot the grid

  • noColorbar (bool, optional) – Turn off the colour bar, useful if multiple plotting plotting routines are used on the same figure.

  • reciprocateX (bool, optional) – Take the reciprocal of the X axis before other transforms

  • reciprocateY (bool, optional) – Take the reciprocal of the Y axis before other transforms

  • trim (bool, optional) – Set the x and y limits to the first and last non zero values along each axis.

  • classes (dict, optional) – A dictionary containing three entries. classes[‘id’] : array_like of same shape as self containing the class id of each element in self. classes[‘cmaps’] : list of matplotlib colourmaps. The number of colourmaps should equal the number of classes. classes[‘labels’] : list of str. The length should equal the number of classes. If classes is provided, alpha is ignored if provided.

Returns:

matplotlib .Axes

Return type:

ax

See also

matplotlib.pyplot.pcolormesh

For additional keyword arguments you may use.

geobipy.src.base.plotting.pcolor_1D(values, y=None, **kwargs)

Create a pseudocolour plot of an array, Actually uses pcolormesh for speed.

Create a colour plot of an array. If the arrays x, y, and values are geobipy.StatArray classes, the axes can be automatically labelled. Can take any other matplotlib arguments and keyword arguments e.g. cmap etc.

Parameters:
  • values (array_like or StatArray) – An array of colour values.

  • x (1D array_like or StatArray) – Horizontal coordinates of the values edges.

  • y (1D array_like or StatArray, optional) – Vertical coordinates of the values edges.

  • log ('e' or float, optional) – Take the log of the colour to a base. ‘e’ if log = ‘e’, and a number e.g. log = 10. Values in c that are <= 0 are masked.

  • equalize (bool, optional) – Equalize the histogram of the colourmap so that all colours have an equal amount.

  • nbins (int, optional) – Number of bins to use for histogram equalization.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’

  • flipY (bool, optional) – Flip the Y axis

  • clabel (str, optional) – colourbar label

  • grid (bool, optional) – Show the grid lines

  • transpose (bool, optional) – Transpose the image

  • noColorbar (bool, optional) – Turn off the colour bar, useful if multiple plotting plotting routines are used on the same figure.

Returns:

matplotlib .Axes

Return type:

ax

See also

matplotlib.pyplot.pcolormesh

For additional keyword arguments you may use.

geobipy.src.base.plotting.pcolor_as_bar(X, Y, values, **kwargs)

Create a pseudocolour plot of a 2D array, Actually uses pcolormesh for speed.

Create a colour plot of a 2D array. If the arrays x, y, and values are geobipy.StatArray classes, the axes can be automatically labelled. Can take any other matplotlib arguments and keyword arguments e.g. cmap etc.

Parameters:
  • values (array_like or StatArray) – A 2D array of colour values.

  • X (1D array_like or StatArray, optional) – Horizontal coordinates of the values edges.

  • Y (1D array_like or StatArray, optional) – Vertical coordinates of the values edges.

  • alpha (scalar or array_like, optional) – If alpha is scalar, behaves like standard matplotlib alpha and opacity is applied to entire plot If array_like, each pixel is given an individual alpha value.

  • alphaColour ('trans' or length 3 array) – If ‘trans’, low alpha values are mapped to transparency If 3 array, each entry is the RGB value of a colour to map to, e.g. white = [1, 1, 1].

  • log ('e' or float, optional) – Take the log of the colour to a base. ‘e’ if log = ‘e’, and a number e.g. log = 10. Values in c that are <= 0 are masked.

  • equalize (bool, optional) – Equalize the histogram of the colourmap so that all colours have an equal amount.

  • nbins (int, optional) – Number of bins to use for histogram equalization.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’

  • flipX (bool, optional) – Flip the X axis

  • flipY (bool, optional) – Flip the Y axis

  • grid (bool, optional) – Plot the grid

  • noColorbar (bool, optional) – Turn off the colour bar, useful if multiple plotting plotting routines are used on the same figure.

  • trim (array_like, optional) – Set the x and y limits to the first and last locations that don’t equal the values in trim.

  • classes (dict, optional) – A dictionary containing three entries. classes[‘id’] : array_like of same shape as self containing the class id of each element in self. classes[‘cmaps’] : list of matplotlib colourmaps. The number of colourmaps should equal the number of classes. classes[‘labels’] : list of str. The length should equal the number of classes. If classes is provided, alpha is ignored if provided.

Returns:

matplotlib .Axes

Return type:

ax

See also

matplotlib.pyplot.pcolormesh

For additional keyword arguments you may use.

geobipy.src.base.plotting.plot(x, y, **kwargs)

Plot y against x

If x and y are StatArrays, the axes are automatically labelled.

Parameters:
  • x (array_like or StatArray) – The abcissa

  • y (array_like or StatArray) – The ordinate, can be upto 2 dimensions.

  • log ('e' or float, optional) – Take the log of the colour to a base. ‘e’ if log = ‘e’, and a number e.g. log = 10. Values in c that are <= 0 are masked.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’.

  • flipX (bool, optional) – Flip the X axis

  • flipY (bool, optional) – Flip the Y axis

  • labels (bool, optional) – Plot the labels? Default is True.

Returns:

matplotlib.Axes

Return type:

ax

See also

matplotlib.pyplot.plot

For additional keyword arguments you may use.

geobipy.src.base.plotting.pretty(ax)

Make a plot with nice axes.

Removes fluff from the axes.

Parameters:

ax (matplotlib .Axes) – A .Axes class from for example ax = plt.subplot(111), or ax = plt.gca()

geobipy.src.base.plotting.scatter2D(x, c, y=None, i=None, *args, **kwargs)

Create a 2D scatter plot.

Create a 2D scatter plot, if the y values are not given, the colours are used instead. If the arrays x, y, and c are geobipy.StatArray classes, the axes can be automatically labelled. Can take any other matplotlib arguments and keyword arguments e.g. markersize etc.

Parameters:
  • x (1D array_like or StatArray) – Horizontal locations of the points to plot

  • c (1D array_like or StatArray) – Colour values of the points

  • y (1D array_like or StatArray, optional) – Vertical locations of the points to plot, if y = None, then y = c.

  • i (sequence of ints or numpy.slice, optional) – Plot a geobipy_kwargs of x, y, c, using the indices in i.

  • log ('e' or float, optional) – Take the log of the colour to base ‘e’ if log = ‘e’, and a number e.g. log = 10. Values in c that are <= 0 are masked.

  • equalize (bool, optional) – Equalize the histogram of the colourmap so that all colours have an equal amount.

  • nbins (int, optional) – Number of bins to use for histogram equalization.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’

  • flipX (bool, optional) – Flip the X axis

  • flipY (bool, optional) – Flip the Y axis

  • noColorbar (bool, optional) – Turn off the colour bar, useful if multiple plotting plotting routines are used on the same figure.

Returns:

matplotlib .Axes

Return type:

ax

See also

matplotlib.pyplot.scatter

For additional keyword arguments you may use.

geobipy.src.base.plotting.setAlphaPerPcolormeshPixel(pcmesh, alphaArray)

Set the opacity of each pixel in a pcolormesh

Parameters:
  • pcmesh (matplotlib.collections.QuadMesh) – pcolormesh object

  • alphaArray (array_like) – Values per pixel each between 0 and 1.

geobipy.src.base.plotting.sizeLegend(values, intervals=None, **kwargs)

Add a legend to a plot if the point sizes have been specified.

If values is an StatArray, labels are generated automatically.

Parameters:
  • values (array_like or StatArray) – The array that was used as the size (s=) in a scatter function.

  • intervals (array_like, optional) – The legend will have items at each value in intervals.

  • **kwargs (dict) – kwargs are applied to plt.legend.

geobipy.src.base.plotting.stackplot2D(x, y, labels=[], colors=['#000000', '#FFFF00', '#1CE6FF', '#FF34FF', '#FF4A46', '#008941', '#006FA6', '#A30059', '#FFDBE5', '#7A4900', '#0000A6', '#63FFAC', '#B79762', '#004D43', '#8FB0FF', '#997D87', '#5A0007', '#809693', '#FEFFE6', '#1B4400', '#4FC601', '#3B5DFF', '#4A3B53', '#FF2F80', '#61615A', '#BA0900', '#6B7900', '#00C2A0', '#FFAA92', '#FF90C9', '#B903AA', '#D16100', '#DDEFFF', '#000035', '#7B4F4B', '#A1C299', '#300018', '#0AA6D8', '#013349', '#00846F', '#372101', '#FFB500', '#C2FFED', '#A079BF', '#CC0744', '#C0B9B2', '#C2FF99', '#001E09', '#00489C', '#6F0062', '#0CBD66', '#EEC3FF', '#456D75', '#B77B68', '#7A87A1', '#788D66', '#885578', '#FAD09F', '#FF8A9A', '#D157A0', '#BEC459', '#456648', '#0086ED', '#886F4C', '#34362D', '#B4A8BD', '#00A6AA', '#452C2C', '#636375', '#A3C8C9', '#FF913F', '#938A81', '#575329', '#00FECF', '#B05B6F', '#8CD0FF', '#3B9700', '#04F757', '#C8A1A1', '#1E6E00', '#7900D7', '#A77500', '#6367A9', '#A05837', '#6B002C', '#772600', '#D790FF', '#9B9700', '#549E79', '#FFF69F', '#201625', '#72418F', '#BC23FF', '#99ADC0', '#3A2465', '#922329', '#5B4534', '#FDE8DC', '#404E55', '#0089A3', '#CB7E98', '#A4E804', '#324E72', '#6A3A4C'], **kwargs)

Plot a 2D array with column elements stacked on top of each other.

Parameters:
  • x (array_like or StatArray) – The abcissa.

  • y (array_like or StatArray, 2D) – The cumulative sum along the columns is taken and stacked on top of each other.

  • labels (list of str, optional) – The labels to assign to each column.

  • colors (matplotlib.colors.LinearSegmentedColormap or list of colours) – The colour used for each column.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’.

Returns:

matplotlib .Axes

Return type:

ax

See also

matplotlib.pyplot.scatterplot

For additional keyword arguments you may use.

geobipy.src.base.plotting.step(x, y, **kwargs)

Plots y against x as a piecewise constant (step like) function.

Parameters:
  • x (array_like)

  • y (array_like)

  • flipY (bool, optional) – Flip the y axis

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’

  • yscale (str, optional) – Scale the y axis? e.g. yscale = ‘linear’ or ‘log’

  • flipX (bool, optional) – Flip the X axis

  • flipY – Flip the Y axis

  • noLabels (bool, optional) – Do not plot the labels

geobipy.src.base.plotting.vlines(*args, **kwargs)

Plot y against x

If x and y are StatArrays, the axes are automatically labelled.

Parameters:
  • x (array_like or StatArray) – The abcissa

  • y (array_like or StatArray) – The ordinate, can be upto 2 dimensions.

  • log ('e' or float, optional) – Take the log of the colour to a base. ‘e’ if log = ‘e’, and a number e.g. log = 10. Values in c that are <= 0 are masked.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’.

  • flipX (bool, optional) – Flip the X axis

  • flipY (bool, optional) – Flip the Y axis

  • labels (bool, optional) – Plot the labels? Default is True.

Returns:

matplotlib.Axes

Return type:

ax

See also

matplotlib.pyplot.plot

For additional keyword arguments you may use.