Plotting¶
-
class
groundhog.general.plotting.
LogPlot
(soilprofile, no_panels=1, logwidth=0.05, fillcolordict={'Clay': 'brown', 'Rock': 'grey', 'Sand': 'yellow'}, soiltypelegend=True, **kwargs)[source]¶ Class for planneled plots with a minilog on the side.
-
add_trace
(x, z, name, panel_no, resetaxisrange=True, **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'$ 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 kwargs: Optional keyword arguments for thego.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_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
-
-
class
groundhog.general.plotting.
LogPlotMatplotlib
(soilprofile, no_panels=1, logwidth=0.05, fillcolordict={'Clay': 'brown', 'Rock': 'grey', 'Sand': 'yellow'}, soiltypelegend=True, 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_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 thego.Scatter
constructor :return: Adds the trace to the specified panel
-
plot_parameter
(parameter, panel_no, name, **kwargs)[source]¶ Plot the trace of a certain parameter in the
SoilProfile
object associated with the logplot on 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 theno_additional_layers
argument. Click on the desired layer transition location in the specified panel (defaultpanel_no=1
) The depth of the layer transition is rounded according to theprecision
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 theSoilProfile
object with the'parametername [units]'
key.
-
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 theSoilProfile
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, **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 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
-
-
groundhog.general.plotting.
generate_html
(outpath, figures, titles, drawnby, report, fignos, rev, projecttitle, subtitle1s, subtitle2s=None, subtitle3s=None, subtitle4s=None, checkedby=None, figure_date='28/08/2022', filename='figures', portraitformat=True, print_message=True)[source]¶ Returns HTML for a series of Plotly portrait figures. The figures are first coerced to the correct format (portrait: H=870 x W=702, landscape: H=600 x W=1050). Standardized font and colors are also set.
Parameters: - outpath – Path where the output is written. Use absolute paths.
- figures – List of Plotly figures
- titles – List of titles for the figures (maximum 90 characters)
- drawnby – Initials of drawer (maximum 3 characters)
- report – Report number (maximum 15 characters)
- fignos – List with figure numbers (maximum 12 characters)
- rev – Revision of the figures (maximum 2 characters)
- date – Date of drawing in %d/%m/%Y format
- projecttitle – Title of the project (maximum 95 characters)
- subtitle1s – List with first subtitles (maximum 120 characters)
- subtitle2s – List with second subtitles (maximum 120 characters) - default is None
- subtitle3s – List with third subtitles (maximum 120 characters) - default is None
- subtitle4s – List with fourth subtitles (maximum 120 characters) - default is None
- checkedby – Initials of the checker (maximum 3 characters)
- filename – Filename for the output, ‘figures’ by default
- portraitformat – Boolean determining whether the figure is portrait or landscape format
- print_message – Defines whether a message is returned to the user
Returns: Writes a file with HTML code to the specified output path
-
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