Ejemplo n.º 1
0
def drawSensors(ax, sensors, diam=None, coords=None, verbose=False, **kwargs):
    """Draw sensor positions as black dots with a given diameter.

    Parameters
    ----------
    sensors : vector or list of RVector3
        list of positions to plot
    diam : float [None]
        diameter of circles (None leads to point distance by 8)
    coords: (int, int) [0, 1]
        Coordinates to take (usually x and y)

    Examples
    --------
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> import pygimli as pg
    >>> from pygimli.mplviewer import drawSensors
    >>> sensors = np.random.rand(5, 2)
    >>> fig, ax = pg.plt.subplots()
    >>> drawSensors(ax, sensors, diam=0.02, coords=[0, 1])
    >>> ax.set_aspect('equal')
    >>> pg.wait()
    """
    if coords is None:
        coords = [0, 2]
        if pg.yVari(sensors):
            coords = [0, 1]

    eCircles = []

    if diam is None:
        eSpacing = sensors[0].distance(sensors[1])
        diam = eSpacing / 8.0

    for i, e in enumerate(sensors):
        if verbose:
            print(e, diam, e[coords[0]], e[coords[1]])
        eCircles.append(
            mpl.patches.Circle((e[coords[0]], e[coords[1]]), diam, **kwargs))

    p = mpl.collections.PatchCollection(eCircles, **kwargs)
    p.set_zorder(100)
    ax.add_collection(p)

    updateAxes_(ax)
Ejemplo n.º 2
0
def drawSensors(ax, sensors, diam=None, coords=None, verbose=False, **kwargs):
    """Draw sensor positions as black dots with a given diameter.

    Parameters
    ----------
    sensors : vector or list of RVector3
        list of positions to plot
    diam : float [None]
        diameter of circles (None leads to point distance by 8)
    coords: (int, int) [0, 1]
        Coordinates to take (usually x and y)

    Examples
    --------
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> import pygimli as pg
    >>> from pygimli.mplviewer import drawSensors
    >>> sensors = np.random.rand(5, 2)
    >>> fig, ax = pg.plt.subplots()
    >>> drawSensors(ax, sensors, diam=0.02, coords=[0, 1])
    >>> ax.set_aspect('equal')
    >>> pg.wait()
    """
    if coords is None:
        coords = [0, 2]
        if pg.yVari(sensors):
            coords = [0, 1]

    eCircles = []

    if diam is None:
        eSpacing = sensors[0].distance(sensors[1])
        diam = eSpacing / 8.0

    for i, e in enumerate(sensors):
        if verbose:
            print(e, diam, e[coords[0]], e[coords[1]])
        eCircles.append(
            mpl.patches.Circle((e[coords[0]], e[coords[1]]), diam, **kwargs))

    p = mpl.collections.PatchCollection(eCircles, **kwargs)
    p.set_zorder(100)
    ax.add_collection(p)

    updateAxes_(ax)
Ejemplo n.º 3
0
def drawSensors(ax, sensors, diam=None, koords=None, verbose=False, **kwargs):
    """Draw sensor positions as black dots with a given diameter.

    Parameters
    ----------

    Examples
    --------
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> from pygimli.mplviewer import drawSensors
    >>> sensors = np.random.rand(5, 2)
    >>> fig, ax = plt.subplots()
    >>> drawSensors(ax, sensors, diam=0.02, koords=[0, 1])
    >>> ax.set_aspect('equal')
    """
    if koords is None:
        koords = [0, 2]
        if pg.yVari(sensors):
            koords = [0, 1]

    eCircles = []

    if diam is None:
        eSpacing = sensors[0].distance(sensors[1])
        diam = eSpacing / 8.0

    for e in sensors:
        if verbose:
            print(e, diam, e[koords[0]], e[koords[1]])
        eCircles.append(mpl.patches.Circle((e[koords[0]], e[koords[1]]), diam))

    p = mpl.collections.PatchCollection(eCircles, **kwargs)
    p.set_zorder(100)
    ax.add_collection(p)

    updateAxes_(ax)