pygmi.vector.graphs#

Plot Vector Data using Matplotlib.

Classes#

MyMplCanvas

Matplotlib canvas widget for the actual plot.

PlotCCoef

GUI to plot correlation coefficients.

PlotHist

GUI to plot histogram from vectors.

PlotLines

GUI to plot lines.

PlotLineMap

GUI to plot a line map.

PlotRose

GUI to plot rose diagrams.

PlotVector

GUI to plot vectors.

Functions#

heatmap(data, row_labels, col_labels, ax, *[, ...])

Create a heatmap from a numpy array and two lists of labels.

annotate_heatmap(im[, data, valfmt, textcolors, threshold])

Annotate a heatmap.

histogram(x[, y, xmin, xmax, bins])

Histogram.

rotate(origin, point, angle)

Rotate a point counterclockwise by a given angle around a given origin.

Module Contents#

class pygmi.vector.graphs.MyMplCanvas(parent=None)#

Bases: matplotlib.backends.backend_qtagg.FigureCanvasQTAgg

Matplotlib canvas widget for the actual plot.

This routine will also allow the picking and movement of nodes of data.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

button_release_callback(event)#

Mouse button release callback.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Button release event.

Return type:

None.

format_coord(x, y)#

Set format coordinate for correlation coefficient plot.

Parameters:
  • x (float) – x coordinate.

  • y (float) – y coordinate.

Returns:

Output string to display.

Return type:

str

motion_notify_callback(event)#

Move mouse callback.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Motion notify event.

Return type:

None.

onpick(event)#

Picker event.

Parameters:

event (matplotlib.backend_bases.PickEvent) – Pick event.

Returns:

Return TRUE if pick succeeded, False otherwise.

Return type:

bool

resizeline(event)#

Resize event.

Parameters:

event (matplotlib.backend_bases.ResizeEvent) – Resize event.

Return type:

None.

textresize(axes)#

Resize the text on a correlation plot when zooming.

Parameters:

axes (Matplotlib axes) – Current Matplotlib axes.

Return type:

None.

update_ccoef(data, style='Normal')#

Update the plot from point data.

Parameters:
  • data (dictionary) – GeoPandas data in a dictionary.

  • style (str) – Style of colour mapping.

Return type:

None.

update_lines(r, data)#

Update the plot from point data.

Parameters:
  • r (numpy array) – array of distances, for the x-axis

  • data (numpy array) – array of data to be plotted on the y-axis

Return type:

None.

update_lmap(data, ival, scale, uselabels)#

Update the plot from line data.

Parameters:
  • data (Pandas dataframe) – Line data

  • ival (dictionary key) – dictionary key representing the line data channel to be plotted.

  • scale (float) – scale of exaggeration for the profile data on the map.

  • uselabels (bool) – boolean choice whether to use labels or not.

Return type:

None.

update_vector(data, col, style=None)#

Update the plot from vector data.

Parameters:
  • data (dictionary) – GeoPandas data in a dictionary.

  • col (str) – Label for column to extract.

  • style (str or None) – Style of colour mapping.

Return type:

None.

update_rose(data, rtype, nbins=8, equal=False)#

Update the rose diagram plot using vector data.

Parameters:
  • data (dictionary) – GeoPandas data in a dictionary. It should be ‘LineString’

  • rtype (int) – Rose diagram type. Can be either 0 or 1.

  • nbins (int, optional) – Number of bins used in rose diagram. The default is 8.

  • equal (bool, optional) – Option for an equal area rose diagram. The default is False.

Return type:

None.

update_hist(data, col, ylog, iscum)#

Update the histogram plot.

Parameters:
  • data (dictionary) – GeoPandas data in a dictionary.

  • col (str) – Label for column to extract.

  • ylog (bool) – Boolean for a log scale on y-axis.

  • iscum (bool) – Boolean for a cumulative distribution.

Return type:

None.

class pygmi.vector.graphs.PlotCCoef(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to plot correlation coefficients.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

change_band()#

Combo box to choose band.

Return type:

None.

run()#

Entry point into the routine, used to run context menu item.

Return type:

None.

class pygmi.vector.graphs.PlotHist(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to plot histogram from vectors.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

change_band()#

Combo box to choose band.

Return type:

None.

run()#

Entry point into the routine, used to run context menu item.

Return type:

None.

class pygmi.vector.graphs.PlotLines(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to plot lines.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

change_band()#

Combo box to choose band.

Return type:

None.

run()#

Entry point into the routine, used to run context menu item.

Return type:

None.

class pygmi.vector.graphs.PlotLineMap(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to plot a line map.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

change_band()#

Combo box to choose band.

Return type:

None.

run()#

Entry point into the routine, used to run context menu item.

Return type:

None.

class pygmi.vector.graphs.PlotRose(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to plot rose diagrams.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

change_band()#

Combo box to choose band.

Return type:

None.

run()#

Entry point into the routine, used to run context menu item.

Return type:

None.

class pygmi.vector.graphs.PlotVector(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to plot vectors.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

change_band()#

Combo box to choose band.

Return type:

None.

run()#

Entry point into the routine, used to run context menu item.

Return type:

None.

pygmi.vector.graphs.heatmap(data, row_labels, col_labels, ax, *, cbar_kw=None, cbarlabel='', **kwargs)#

Create a heatmap from a numpy array and two lists of labels.

From Matplotlib.org

Parameters:
  • data – A 2D numpy array of shape (M, N).

  • row_labels – A list or array of length M with the labels for the rows.

  • col_labels – A list or array of length N with the labels for the columns.

  • ax – A matplotlib.axes.Axes instance to which the heatmap is plotted.

  • cbar_kw – A dictionary with arguments to matplotlib.Figure.colorbar. Optional.

  • cbarlabel – The label for the colorbar. Optional.

  • **kwargs – All other arguments are forwarded to imshow.

pygmi.vector.graphs.annotate_heatmap(im, data=None, valfmt='{x:.2f}', textcolors=('black', 'white'), threshold=None, **textkw)#

Annotate a heatmap.

From Matplotlib.org.

Parameters:
  • im – The AxesImage to be labelled.

  • data – Data used to annotate. If None, the image’s data is used. Optional.

  • valfmt – The format of the annotations inside the heatmap. This should either use the string format method, e.g. “$ {x:.2f}”, or be a matplotlib.ticker.Formatter. Optional.

  • textcolors – A pair of colours. The first is used for values below a threshold, the second for those above. Optional.

  • threshold – Value in data units according to which the colours from textcolors are applied. If None (the default) uses the middle of the colormap as separation. Optional.

  • **kwargs – All other arguments are forwarded to each call to text used to create the text labels.

pygmi.vector.graphs.histogram(x, y=None, xmin=None, xmax=None, bins=10)#

Histogram.

Calculate histogram of a set of data. It is different from a conventional histogram in that instead of summing elements of specific values, this allows the sum of weights/probabilities on a per element basis.

Parameters:
  • x (numpy array) – Input data

  • y (numpy array) – Input data weights. The default is None.

  • xmin (float) – Lower value for the bins. The default is None.

  • xmax (float) – Upper value for the bins. The default is None.

  • bins (int) – number of bins. The default is 10.

Returns:

  • hist (numpy array) – The values of the histogram

  • bin_edges (numpy array) – bin edges of the histogram

pygmi.vector.graphs.rotate(origin, point, angle)#

Rotate a point counterclockwise by a given angle around a given origin.

The angle should be given in radians.

Parameters:
  • origin (list) – List containing origin point (ox, oy)

  • point (list) – List containing point to be rotated (px, py)

  • angle (float) – Angle in radians.

Returns:

  • qx (float) – Rotated x-coordinate.

  • qy (float) – Rotated y-coordinate.