plot

petrophys.api.plot

Also available as petrophys.plot

plot(
well,
*,
top=None,
bottom=None,
curves=None,
tracks=None,
template='auto',
template_xml_path=None,
formations=None,
lithology=None,
lithology_codes=None,
formation_name=None,
figsize=None,
strict=False,
curve_aliases=None,
curve_styles=None,
)[source]

Draw a multi-track log plot of a well or an interpretation result.

Several wells (a list of wells, results or files, the wells read() returns for a folder, the results interpret() returns for several wells, or a folder or file pattern) give one of two plots. A mapping of labels to wells or results ({"archie": run_a, "indonesia": run_b}) names each by its label, so runs of one well can be told apart:

  • without curves, each well’s own log plot, with the other options applied to each (MultiWellPlot): shown one after another, .save(folder) writes a file per well, and the figures are drawn one at a time;

  • with curves, one figure comparing the wells (WellComparisonPlot): a track per curve, every well’s curve in it, top and bottom bounding the depth axis and figsize its size.

Parameters:
  • well (Well, DynamicWorkflowResult, str, Path, list or mapping) – Well to plot, or a well file to read with read(). Passing the result of interpret() plots the interpreted well, including calculated curves. Several wells as above; a mapping labels them.

  • top (float, optional) – Top and bottom depth of the plot window, in the well’s depth unit. Default to the top and bottom of the logged interval.

  • bottom (float, optional) – Top and bottom depth of the plot window, in the well’s depth unit. Default to the top and bottom of the logged interval.

  • curves (str or sequence of str, optional) – Draw only these curves (the well’s own names or standard names such as "GR"), each in its track; curves no track takes get a track titled by their names. Tracks left empty are not drawn; lithology intervals attached by read() stay as the lithology column.

  • tracks (str or sequence of str, optional) – Track names to show, in order (e.g. ["GAMMA / HOLE", "RESISTIVITY"]; [track.display_name for track in viewer.template.tracks] lists the names of a plot’s tracks). Defaults to every track the template can fill, apart from the "auto" layout’s optional tracks of computed profiles (TEMPERATURE, RW / RMF), which are listed in viewer.optional_tracks and drawn when named here.

  • template (str, default "auto") – Built-in layout. "auto" builds tracks from the curves present; "raw", "petrophysics", "minerals" and "comprehensive" are fixed layouts; "geolink_full" is another name for "comprehensive".

  • template_xml_path (str or Path, optional) – Custom XML template; overrides template.

  • formations (path, DataFrame, mapping, or sequence, optional) – Formation tops to annotate, as for read(). Defaults to the formations attached by read().

  • lithology (path or DataFrame, optional) – Lithology intervals to display instead of embedded lithology, as for read().

  • lithology_codes (mapping, path or DataFrame, optional) – Codebook of a lithology code curve: a mapping of code to rock name, or a table that petrophys.io.read_lithology_codes() reads.

  • formation_name (str, optional) – Formation name shown in the plot title.

  • figsize ((float, float), optional) – Figure size in inches.

  • strict (bool, default False) – If True, curves required by a fixed template must exist (a missing one raises ValueError); otherwise missing curves are skipped and listed in viewer.warnings. Tracks left out because the well has none of their curves, or no data in the depth window, are listed in viewer.omitted_tracks.

  • curve_aliases (mapping, path or DataFrame, optional) – Your names for standard curves ({"GAMMA_RAY_1": "GR"} or a CSV/Excel table), so they fill the right tracks; as for read().

  • curve_styles (mapping, optional) – Style changes per curve, keyed by standard or the well’s own name: {"GR": {"color": "black", "right": 200}, "RDEP": {"line_width": 1.5}}. Keys: color, left, right, line_width, line_style, alpha, fill ("left"/"right"), fill_color, fill_alpha, marker, marker_size, display_name, left_crossover, right_crossover, and the template fill fields fill_color_map, left_color_value, right_color_value, left_cutoff_fill and right_cutoff_fill. XML templates (template_xml_path) remain the way to define whole layouts.

Returns:

The rendered viewer, a matplotlib figure shown inline in a notebook. Use .save(path) (png, pdf, svg, … by the extension), .show() or .close(); .fig and .axes are the figure and its tracks, and .warnings lists anything that could not be drawn as requested.

Return type:

LogViewer, MultiWellPlot or WellComparisonPlot

Raises:
  • TypeError – If well is not a well, an interpretation result, a well file or several of them, or a comparison (several wells with curves) is given an option of a single-well plot (tracks, template, formations, lithology, lithology_codes, formation_name, curve_styles or template_xml_path).

  • ValueError – If a name in curves or tracks is not on the plot, both curves and tracks are given for one well, template is not a built-in layout, a curve_styles key is unknown, or the list of wells is empty.

Examples

>>> import petrophys as pp
>>> viewer = pp.plot(pp.sample("30_6-5"), top=2800, bottom=3000)
>>> viewer.save("well.png")
>>> pp.plot(results).save("plots/")
>>> pp.plot(results, curves=["GR", "RDEP", "PHIE"]).save("compare.png")
>>> pp.plot({"archie": run_a, "indonesia": run_b}, curves=["SW"])