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

Interface for 2D and 3D visualizations.

Module overview


Drawing functions using Matplotlib.


Pyvista based drawing functions used by pygimli.viewer.

Functions#, 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.

  • 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:


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.


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

  • and a colorbar.

See also


pygimli.viewer.showMesh(mesh, data=None, 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.

  • 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.PosVector – vector field

    forward to pygimli.viewer.mpl.drawStreams

    . pg.core.stdVectorRVector3 – sensor positions

    forward to pygimli.viewer.mpl.drawSensors

  • block (bool [False]) – Force to open the Figure of your content and blocks the script until you close the current figure. Same like; pg.wait()

  • 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.

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

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

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

  • boundaryMarkers (bool [False]) – Highlight boundaries with marker !=0 and add Marker annotation. Applies pygimli.viewer.mpl.drawBoundaryMarkers. Dictionary “boundaryProps” can be added and will be forwarded to pygimli.viewer.mpl.drawBoundaryMarkers.

Keyword Arguments:
  • 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 True.

  • boundaryProps (dict) – Arguments for plotboundar

  • hold (bool [pg.hold()]) – Holds back the opening of the Figure. If set to True [default] nothing happens until you either force another show with hold=False or block=True or call pg.wait() or If hold is set to False your script will open the figure and continue working. You can change global hold with pg.hold(bool).

  • functions (All remaining will be forwarded to the draw) –

  • respectively. (and matplotlib methods,) –


>>> 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)


  • ax (matplotlib.axes)

  • cBar (matplotlib.colorbar)