pygimli.viewer

Note

For 2D and 3D visualizations, we rely on matplotlib (www.matplotlib.org) and pyvista (www.pyvista.org), respectively.

Interface for 2D and 3D visualizations.

Module overview

mpl

Matplotlib drawing functions used by pygimli.viewer.

pv

Pyvista based drawing functions used by pygimli.viewer.

Functions

pygimli.viewer.show(obj=None, data=None, **kwargs)[source]

Mesh and model visualization.

Syntactic sugar to show a obj with data. Forwards to a known visualization for obj. Typical is pygimli.viewer.showMesh or pygimli.viewer.mayaview.showMesh3D to show most of the typical 2D and 3D content. See tutorials and examples for usage hints. An empty show call creates an empty ax window.

Parameters
  • obj (obj) – obj can be so far. * GIMLI::Mesh or list of meshes * DataContainer * pg.core.Sparse[Map]Matrix

  • data (iterable) – Optionally data to visualize. See appropriate show function.

Keyword Arguments

**kwargs

Additional kwargs forward to appropriate show functions.

  • axaxe [None]

    Matplotlib axes object. Create a new if necessary.

  • fitViewbool [True]

    Scale x and y limits to match the view.

Returns

  • Return the results from the showMesh functions. Usually the axe object*

  • and a colorbar.

See also

showMesh()

pygimli.viewer.showMesh(mesh, data=None, hold=False, block=False, colorBar=None, label=None, coverage=None, ax=None, savefig=None, showMesh=False, showBoundary=None, markers=False, **kwargs)[source]

2D Mesh visualization.

Create an axis object and plot a 2D mesh with given node or cell data. Returns the axis and the color bar. The type of data determines the appropriate draw method.

Parameters
  • mesh (GIMLI::Mesh) – 2D or 3D GIMLi mesh

  • data (iterable [None]) –

    Optionally data to visualize.

    . None (draw mesh only)

    forward to pygimli.viewer.mpl.drawMesh or if no cells are given: forward to pygimli.viewer.mpl.drawPLC

    . [[marker, value], …]

    List of Cellvalues per cell marker forward to pygimli.viewer.mpl.drawModel

    . float per cell – model, patch

    forward to pygimli.viewer.mpl.drawModel

    . float per node – scalar field

    forward to pygimli.viewer.mpl.drawField

    . iterable of type [float, float] – vector field

    forward to pygimli.viewer.mpl.drawStreams

    . pg.core.R3Vector – vector field

    forward to pygimli.viewer.mpl.drawStreams

    . pg.core.stdVectorRVector3 – sensor positions

    forward to pygimli.viewer.mpl.drawSensors

  • hold (bool [false]) – Set interactive plot mode for matplotlib. If this is set to false [default] your script will open a window with the figure and draw your content. If set to true nothing happens until you either force another show with hold=False, you call plt.show() or pg.wait(). If you want show with stopping your script set block = True.

  • block (bool [false]) – Force show drawing your content and block the script until you close the current figure.

  • colorBar (bool [None], Colorbar) – Create and show a colorbar. If colorBar is a valid colorbar then only its values will be updated.

  • label (str) – Set colorbar label. If set colorbar is toggled to True. [None]

  • coverage (iterable [None]) – Weight data by the given coverage array and fadeout the color.

  • ax (matplotlib.Axes [None]) – Instead of creating a new and empty ax, just draw into the given one. Useful to combine multiple plots into one figure.

  • savefig (string) – Filename for a direct save to disc. The matplotlib pdf-output is a little bit big so we try an epstopdf if the .eps suffix is found in savefig

  • showMesh (bool [False]) – Shows the mesh itself additional.

  • showBoundary (bool [None]) – Shows all boundary with marker != 0. A value None means automatic True for cell data and False for node data.

  • marker (bool [False]) – Show mesh and boundary marker.

Keyword Arguments

**kwargs

  • xlabel: str [None]

    Add label to the x axis

  • ylabel: str [None]

    Add label to the y axis

fitView: bool

Fit the axes limits to the all content of the axes. Default is True.

All remaining will be forwarded to the draw functions and matplotlib methods, respectively.

>>> import pygimli as pg
>>> import pygimli.meshtools as mt
>>> world = mt.createWorld(start=[-10, 0], end=[10, -10],
...                        layers=[-3, -7], worldMarker=False)
>>> mesh = mt.createMesh(world, quality=32, area=0.2, smooth=[1, 10])
>>> _ = pg.viewer.showMesh(mesh, markers=True)

(png, pdf)

../../_images/pygimli-viewer-1.png
Returns

  • ax (matplotlib.axes)

  • cBar (matplotlib.colorbar)