pygmi.vector.graphs#
Plot vector data using Matplotlib.
Classes#
GUI to plot correlation coefficients. |
|
GUI to plot histogram from vectors. |
|
GUI to plot lines. |
|
GUI to plot a line map. |
|
GUI to plot rose diagrams. |
|
GUI to plot vectors. |
Functions#
|
Create a heatmap from a numpy array and two lists of labels. |
|
Annotate a heatmap. |
|
Histogram. |
|
Rotate a point counterclockwise by a given angle around a given origin. |
Module Contents#
- class pygmi.vector.graphs.PlotCCoef(parent=None)#
Bases:
pygmi.misc.ContextModuleGUI to plot correlation coefficients.
- Parameters:
parent – Reference to the parent routine. The default is None.
- change_band()#
Combo box to choose band.
- 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 | None
- run()#
Entry point into the routine, used to run context menu item.
- textresize(axes)#
Resize the text on a correlation plot when zooming.
- Parameters:
axes (matplotlib.axes.Axes) – Current Matplotlib axes.
- update_ccoef()#
Update the plot from point data.
- class pygmi.vector.graphs.PlotHist(parent=None)#
Bases:
pygmi.misc.ContextModuleGUI to plot histogram from vectors.
- Parameters:
parent – Reference to the parent routine. The default is None.
- change_band()#
Combo box to choose band.
- run()#
Entry point into the routine, used to run context menu item.
- update_hist(data, col, ylog, iscum)#
Update the histogram plot.
- Parameters:
data (geopandas.GeoDataFrame) – Input GeoDataFrame.
col (str) – Label for column to extract.
ylog (bool) – Boolean for a log scale on y-axis.
iscum (bool) – Boolean for a cumulative distribution.
- class pygmi.vector.graphs.PlotLines(parent=None)#
Bases:
pygmi.misc.ContextModuleGUI to plot lines.
- Parameters:
parent – Reference to the parent routine. The default is None.
- change_band()#
Combo box to choose band.
- run()#
Entry point into the routine, used to run context menu item.
- update_lines(r, data)#
Update the plot from point data.
- Parameters:
r (numpy.typing.NDArray) – Array of distances, for the x-axis
data (numpy.typing.NDArray) – Array of data to be plotted on the y-axis
- class pygmi.vector.graphs.PlotLineMap(parent=None)#
Bases:
pygmi.misc.ContextModuleGUI to plot a line map.
- Parameters:
parent – Reference to the parent routine. The default is None.
- change_band()#
Combo box to choose band.
- run()#
Entry point into the routine, used to run context menu item.
- update_lmap(data, ival, scale, uselabels)#
Update the plot from line data.
- Parameters:
data (geopandas.GeoDataFrame) – Line data
ival (str | float) – 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.
- class pygmi.vector.graphs.PlotRose(parent=None)#
Bases:
pygmi.misc.ContextModuleGUI to plot rose diagrams.
- Parameters:
parent – Reference to the parent routine. The default is None.
- change_band()#
Combo box to choose band.
- run()#
Entry point into the routine, used to run context menu item.
- update_rose(data, rtype, nbins=8, equal=False, mono=False, showmap=True)#
Update the rose diagram plot using vector data.
- Parameters:
data (geopandas.GeoDataFrame) – GeoPandas data.
rtype (int) – Rose diagram type. Can be either 0 or 1.
nbins (int) – Number of bins used in rose diagram. The default is 8.
equal (bool) – Option for an equal area rose diagram. The default is False.
mono (bool) – Option for a monochrome rose diagram. The default is False.
showmap (bool) – Option to show a map. The default is True.
- class pygmi.vector.graphs.PlotVector(parent=None)#
Bases:
pygmi.misc.ContextModuleGUI to plot vectors.
- Parameters:
parent – Reference to the parent routine. The default is None.
- change_band()#
Combo box to choose band.
- run()#
Entry point into the routine, used to run context menu item.
- update_vector(data, col, style=None)#
Update the plot from vector data.
- Parameters:
data (geopandas.GeoDataFrame) – GeoDataFrame.
col (str) – Label for column to extract.
style (bool | None) – Style of colour mapping.
- 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 (numpy.typing.NDArray) – A 2D numpy array of shape (M, N).
row_labels (list | numpy.typing.NDArray) – A list or array of length M with the labels for the rows.
col_labels (list | numpy.typing.NDArray) – A list or array of length N with the labels for the columns.
ax (matplotlib.axes.Axes) – A matplotlib.axes.Axes instance to which the heatmap is plotted.
cbar_kw (dict | None) – A dictionary with arguments to matplotlib.Figure.colorbar. Optional.
cbarlabel (str) – The label for the colorbar. Optional.
**kwargs – All other arguments are forwarded to imshow.
- Returns:
im (
matplotlib.image.AxesImage) – Image for map.cbar (
matplotlib.colorbar.Colorbar) – Colour bar for map
- Return type:
tuple[matplotlib.image.AxesImage, matplotlib.colorbar.Colorbar]
- pygmi.vector.graphs.annotate_heatmap(im, data=None, ivalfmt='{x:.2f}', textcolors=('black', 'white'), ithreshold=None, **textkw)#
Annotate a heatmap.
From Matplotlib.org.
- Parameters:
im (matplotlib.image.AxesImage) – The AxesImage to be labelled.
data (list | numpy.typing.NDArray | None) – Data used to annotate. If None, the image’s data is used. Optional.
ivalfmt (str | matplotlib.ticker.Formatter) – 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 (list[str] | tuple[str]) – A pair of colours. The first is used for values below a threshold, the second for those above. Optional.
ithreshold (float | None) – 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.
**textkw – All other arguments are forwarded to each call to text used to create the text labels.
- Returns:
List of text
- Return type:
listofstr
- 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.typing.NDArray) – Input data
y (numpy.typing.NDArray | None) – Input data weights. The default is None.
xmin (float | None) – Lower value for the bins. The default is None.
xmax (float | None) – Upper value for the bins. The default is None.
bins (int) – Number of bins. The default is 10.
- Returns:
hist (
ndarray) – The values of the histogrambin_edges (
ndarray) – Bin edges of the histogram
- Return type:
tuple[numpy.typing.NDArray, numpy.typing.NDArray]
- 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[float]) – List containing origin point (ox, oy)point (
list[float]) – List containing point to be rotated (px, py)angle (
float) – Angle in radians.
- Returns:
qx (
float) – Rotated x-coordinate.qy (
float) – Rotated y-coordinate.
- Return type:
tuple[float, float]