Plotting

class groundhog.general.plotting.LogPlot(soilprofile, no_panels=1, logwidth=0.05, fillcolordict={'Clay': 'brown', 'Rock': 'grey', 'Sand': 'yellow'}, soiltypelegend=True, soiltypecolumn='Soil type', line_width=1, **kwargs)[source]

Class for planneled plots with a minilog on the side.

add_soilparameter_trace(parametername, panel_no, legendname=None, resetaxisrange=False, **kwargs)[source]

Adds a trace to the plot based on a soil parameter available in the SoilProfile. By default, lines are added but optional keyword arguments can be added for go.Scatter as **kwargs :param parametername: Name of the soil parameter (with units) e.g. 'Su [kPa]' when 'Su from [kPa]' and 'Su to [kPa]' are available in the SoilProfile :param panel_no: Panel to plot the trace on (1-indexed) :param legendname: Name for the trace (LaTeX allowed, e.g. r'$ \alpha $'), default is None to use parametername :param resetaxisrange: Boolean determining whether the axis range needs to be reset to fit this trace :param kwargs: Optional keyword arguments for the go.Scatter constructor :return: Adds the trace to the specified panel

add_trace(x, z, name, panel_no, resetaxisrange=False, **kwargs)[source]

Adds a trace to the plot. By default, lines are added but optional keyword arguments can be added for go.Scatter as **kwargs :param x: Array with the x-values :param z: Array with the z-values :param name: Name for the trace (LaTeX allowed, e.g. r'$ \alpha $') :param panel_no: Panel to plot the trace on (1-indexed) :param resetaxisrange: Boolean determining whether the axis range needs to be reset to fit this trace :param kwargs: Optional keyword arguments for the go.Scatter constructor :return: Adds the trace to the specified panel

set_size(width, height)[source]

Adjust the size of the plot :param width: Width of the plot in pixels :param height: Height of the plot in pixels :return: Adjust the height and width as specified

set_title(title)[source]

Set a title for the plot :param title: Title for the plot :return: Sets the title as specified

set_xaxis(title, panel_no, **kwargs)[source]

Changes the X-axis title of a panel :param title: Title to be set (LaTeX allowed, e.g. r'$ lpha $') :param panel_no: Panel number (1-indexed) :param kwargs: Additional keyword arguments for the axis layout update function, e.g. range=(0, 100) :return: Adjusts the X-axis of the specified panel

set_zaxis(title, **kwargs)[source]

Changes the Z-axis :param title: Title to be set (LaTeX allowed, e.g. r'$ lpha $') :param kwargs: Additional keyword arguments for the axis layout update function, e.g. range=(0, 100) :return: Adjusts the Z-axis

class groundhog.general.plotting.LogPlotMatplotlib(soilprofile, no_panels=1, logwidth=0.05, fillcolordict={'Clay': 'brown', 'Rock': 'grey', 'Sand': 'yellow', 'Silt': 'green'}, hatchpatterns={'Clay': '////', 'Rock': 'oo', 'Sand': '...', 'Silt': '|||'}, soiltypelegend=True, soiltypecolumn='Soil type', edgecolor='black', figheight=6, plot_layer_transitions=True, showgrid=True, **kwargs)[source]

Class for planneled plots with a minilog on the side, using the Matplotlib plotting backend

add_soilparameter_trace(parametername, panel_no, legendname=None, resetaxisrange=False, line=True, showlegend=False, **kwargs)[source]

Adds a trace to the plot based on a soil parameter available in the SoilProfile. By default, lines are added but optional keyword arguments can be added for plt.plot as **kwargs :param parametername: Name of the soil parameter (with units) e.g. 'Su [kPa]' when 'Su from [kPa]' and 'Su to [kPa]' are available in the SoilProfile :param panel_no: Panel to plot the trace on (1-indexed) :param legendname: Label for the trace (LaTeX allowed, e.g. r'$ \alpha $') :param resetaxisrange: Boolean determining whether the axis range needs to be reset to fit this trace :param line: Boolean determining whether the data needs to be shown as a line or as individual markers :param showlegend: Boolean determining whether the trace name needs to be added to the legend entries :param kwargs: Optional keyword arguments for the go.Scatter constructor :return: Adds the trace to the specified panel

add_trace(x, z, name, panel_no, resetaxisrange=False, line=True, showlegend=False, **kwargs)[source]

Adds a trace to the plot. By default, lines are added but optional keyword arguments can be added for plt.plot as **kwargs :param x: Array with the x-values :param z: Array with the z-values :param name: Label for the trace (LaTeX allowed, e.g. r'$ lpha $') :param panel_no: Panel to plot the trace on (1-indexed) :param resetaxisrange: Boolean determining whether the axis range needs to be reset to fit this trace :param line: Boolean determining whether the data needs to be shown as a line or as individual markers :param showlegend: Boolean determining whether the trace name needs to be added to the legend entries :param kwargs: Optional keyword arguments for the go.Scatter constructor :return: Adds the trace to the specified panel

save_fig(path, dpi=250, bbox_inches='tight', pad_inches=1)[source]

Exports the figure to png format

Parameters:
  • path – Path of the figure (filename ends in .png)

  • dpi – Output resolution

  • bbox_inches – Setting for the bounding box

  • pad_inches – Inches for padding

select_additional_layers(no_additional_layers, panel_no=1, precision=2)[source]

Allows for the selection of additional layer transitions for the SoilProfile object. The number of additional transition is controlled by the no_additional_layers argument. Click on the desired layer transition location in the specified panel (default panel_no=1) The depth of the layer transition is rounded according to the precision argument. Default=2 for cm accuracy.

select_constant(panel_no, parametername, units, nan_tolerance=0.1)[source]

Selects a constant value in each layer. Click the desired value in each layer, working from the top down. If a nan value needs to be set in a layer, click sufficiently close to the minimum of the x axis. The nan_tolerance argument determines which values are interpreted as nan. The parameter is added to the SoilProfile object with the 'parametername [units]' key.

select_layering(panel_no=1, precision=2, stop_threshold=0)[source]

Allows for the selection of layer transitions for the SoilProfile object. The number of additional transition is controlled by how often the user clicks. Click on the desired layer transition location in the specified panel (default panel_no=1). The selection stops when the user clicks on a point with x-coordinate below the stop_threshold. The depth of the layer transition is rounded according to the precision argument. Default=2 for cm accuracy.

select_linear(panel_no, parametername, units, nan_tolerance=0.1)[source]

Selects a linear variation in each layer. Click the desired value at each layer boundary. Note that a value needs to be selected at the top and bottom of each layer (2 x no layers clicks). If a nan value needs to be set in a layer, click sufficiently close to the minimum of the x axis. The nan_tolerance argument determines which values are interpreted as nan. The parameter is added to the SoilProfile object with the 'parametername [units]' key.

set_size(width, height)[source]

Adjust the size of the plot :param width: Width of the plot in inches :param height: Height of the plot in inches :return: Adjust the height and width as specified

set_xaxis_range(min_value, max_value, panel_no, ticks=None, **kwargs)[source]

Changes the X-axis range of a panel :param min_value: Minimum value of the plot panel range :param max_value: Maximum value of the plot panel range :param panel_no: Panel number (1-indexed) :param ticks: List of ticks to set (default=None for Matplotlib defaults) :param kwargs: Additional keyword arguments for the set_xlim method :return: Adjusts the X-axis range of the specified panel

set_xaxis_title(title, panel_no, size=15, **kwargs)[source]

Changes the X-axis title of a panel :param title: Title to be set (LaTeX allowed, e.g. r'$ lpha $') :param panel_no: Panel number (1-indexed) :param kwargs: Additional keyword arguments for the axis layout update function, e.g. range=(0, 100) :return: Adjusts the X-axis of the specified panel

set_zaxis_range(min_depth, max_depth, ticks=None, **kwargs)[source]

Changes the Z-axis :param min_depth: Minimum depth of the plot :param max_depth: Maximum depth of the plot :param ticks: List of ticks to set (default=None for Matplotlib defaults) :param kwargs: Additional keyword arguments for the set_ylim method :return: Adjusts the Z-axis range

set_zaxis_title(title, size=15, **kwargs)[source]

Changes the Z-axis :param title: Title to be set (LaTeX allowed, e.g. r'$ lpha $') :param kwargs: Additional keyword arguments for the set_label method :return: Adjusts the Z-axis title

groundhog.general.plotting.peak_picker(x, y, correct_selected_point=True)[source]

Generates an interactive Matplotlib plot which allows you to pick the peak from a graph with e.g. load-displacement data

Parameters:
  • x – Array with x-values

  • y – Array with y-values

  • correct_selected_point – Boolean determining whether a correction is applied to interpolate the peak based on the selected value of X for the peak

Returns:

Dictionary with the following keys:

  • ’x100’: x-coordinate of the peak

  • ’y100’: y-coordinate of the peak

  • ’x50’: x-coordinate where y reached 50% of its peak y

  • ’y50’: y-coordinate with y equal to 50% of the peak y

groundhog.general.plotting.plot_with_log(x=[[]], z=[[]], names=[[]], showlegends=None, hide_all_legends=False, modes=None, markerformats=None, soildata=None, fillcolordict={'CLAY': 'brown', 'ROCK': 'grey', 'SAND': 'yellow', 'SILT': 'green'}, depth_from_key='Depth from [m]', depth_to_key='Depth to [m]', colors=None, logwidth=0.05, xtitles=[], ztitle=None, xranges=None, zrange=None, ztick=None, dticks=None, layout={}, showfig=True)[source]

Plots a given number of traces in a plot with a soil mini-log on the left hand side. The traces are given as a list of lists, the traces are grouped per plotting panel. For example x=[[np.linspace(0, 1, 100), np.logspace(0,2,100)], [np.linspace(1, 3, 100), ]] leads to the first two traces plotted in the first panel and one trace in the second panel. The same goes for the z arrays, trace names, …

Parameters:
  • x – List of lists of x-arrays for the traces

  • z – List of lists of z-arrays for the traces

  • names – List of lists of names for the traces (used in legend)

  • showlegends – Array of booleans determining whether or not to show the trace in the legend. Showing/hiding legends can be specified per trace.

  • hide_all_legends – Boolean indicating whether all legends need to be hidden (default=False).

  • modes – List of display modes for the traces (select from ‘lines’, ‘markers’ or ‘lines+markers’

  • markerformats – List of formats for the markers (see Plotly docs for more info)

  • soildata – Pandas dataframe with keys ‘Soil type’: Array with soil type for each layer, ‘Depth from [m]’: Array with start depth for each layer, ‘Depth to [m]’: Array with bottom depth for each layer

  • fillcolordict – Dictionary with fill colours (default yellow for ‘SAND’, brown from ‘CLAY’ and grey for ‘ROCK’)

  • depth_from_key – Key for the column with start depths of each layer

  • depth_to_key – Key for the column with end depths of each layer

  • colors – List of colours to be used for plotting (default = default Plotly colours)

  • logwidth – Width of the soil width as a ratio of the total plot with (default = 0.05)

  • xtitles – Array with X-axis titles for the panels

  • ztitle – Depth axis title (Depth axis is shared between all panels)

  • xranges – List with ranges to be used for X-axes

  • zrange – Range to be used for Y-axis

  • ztick – Tick interval to be used for the Y-axis

  • dticks – List of tick intervals to be used for the X-axes

  • layout – Dictionary with the layout settings

  • showfig – Boolean determining whether the figure needs to be shown

Returns:

Plotly figure object which can be further modified