The fatiando package has been deprecated. Please check out the new tools in the Fatiando a Terra website: www.fatiando.org

Plot 3D objects in Mayavi2 (fatiando.vis.myv)

Wrappers for calls to Mayavi2’s mlab module for plotting fatiando.mesher objects and automating common tasks.

Warning

This module will be removed in v0.7.

Objects

Misc objects

Helpers


fatiando.vis.myv.axes(plot, nlabels=5, extent=None, ranges=None, color=(0, 0, 0), width=2, fmt='%-#.2f')[source]

Add an Axes module to a Mayavi2 plot or dataset.

Parameters:

  • plot

    Either the plot (as returned by one of the plotting functions of this module) or a TVTK dataset.

  • nlabels
    : int

    Number of labels on the axes

  • extent
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    Default if the objects extent.

  • ranges
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    What will be display in the axes labels. Default is extent

  • color
    : tuple = (r, g, b)

    RGB of the color of the axes and text

  • width
    : float

    Line width

  • fmt
    : str

    Label number format

Returns:

  • axes
    : Mayavi axes instace

    The axes object in the pipeline

fatiando.vis.myv.continents(color=(0, 0, 0), linewidth=1, resolution=2, opacity=1, radius=6378137.0)[source]

Plot the outline of the continents.

Parameters:

  • color
    : tuple

    RGB color of the lines. Default = black

  • linewidth
    : float

    The width of the continent lines

  • resolution
    : float

    The data_source.on_ratio parameter that controls the resolution of the continents

  • opacity
    : float

    The opacity of the lines. Must be between 0 and 1

  • radius
    : float

    The radius of the sphere where the continents will be plotted. Defaults to the mean Earth radius

Returns:

  • continents
    : Mayavi surface

    The Mayavi surface element of the continents

fatiando.vis.myv.core(inner=False, color=(1, 0, 0), opacity=1)[source]

Draw a sphere representing the Earth’s core.

Parameters:

  • inner
    : True or False

    If True, will use the radius of the inner core, else the outer core.

  • color
    : tuple

    RGB color of the sphere. Defaults to red.

  • opacity
    : float

    The opacity of the sphere. Must be between 0 and 1

Returns:

  • sphere
    : Mayavi surface

    The Mayavi surface element of the sphere

fatiando.vis.myv.earth(color=(0.4, 0.5, 1.0), opacity=1)[source]

Draw a sphere representing the Earth.

Parameters:

  • color
    : tuple

    RGB color of the sphere. Defaults to ocean blue.

  • opacity
    : float

    The opacity of the sphere. Must be between 0 and 1

Returns:

  • sphere
    : Mayavi surface

    The Mayavi surface element of the sphere

fatiando.vis.myv.figure(size=None, zdown=True, color=(1, 1, 1))[source]

Create a default figure in Mayavi with white background

Parameters:

  • size
    : tuple = (dx, dy)

    The size of the figure. If None will use the default size.

  • zdown
    : True or False

    If True, will turn the figure upside-down to make the z-axis point down

  • color
    : tuple = (r, g, b)

    RGB of the color of the background

Return:

  • fig
    : Mayavi figure object

    The figure

fatiando.vis.myv.meridians(longitudes, color=(0, 0, 0), linewidth=1, opacity=1)[source]

Draw meridians on the Earth.

Parameters:

  • longitudes
    : list

    The longitudes where the meridians will be drawn.

  • color
    : tuple

    RGB color of the lines. Defaults to black.

  • linewidth
    : float

    The width of the lines

  • opacity
    : float

    The opacity of the lines. Must be between 0 and 1

Returns:

  • lines
    : Mayavi surface

    The Mayavi surface element of the lines

fatiando.vis.myv.outline(extent=None, color=(0, 0, 0), width=2, scale=(1, 1, 1))[source]

Create a default outline in Mayavi2.

Parameters:

  • extent
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    Default if the objects extent.

  • color
    : tuple = (r, g, b)

    RGB of the color of the axes and text

  • width
    : float

    Line width

  • scale
    : (slon, slat, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

Returns:

  • outline
    : Mayavi outline instace

    The outline in the pipeline

fatiando.vis.myv.parallels(latitudes, color=(0, 0, 0), linewidth=1, opacity=1)[source]

Draw parallels on the Earth.

Parameters:

  • latitudes
    : list

    The latitudes where the parallels will be drawn.

  • color
    : tuple

    RGB color of the lines. Defaults to black.

  • linewidth
    : float

    The width of the lines

  • opacity
    : float

    The opacity of the lines. Must be between 0 and 1

Returns:

  • lines
    : list

    List of the Mayavi surface elements of each line

fatiando.vis.myv.points(points, color=(0, 0, 0), size=200.0, opacity=1, spherical=False)[source]

Plot a series of 3D points.

Note

Still doesn’t plot points with physical properties.

Parameters:

  • points
    : list

    The list of points to plot. Each point is an [x, y, z] list with the x, y, and z coordinates of the point

  • color
    : tuple = (r, g, b)

    RGB of the color of the points

  • size
    : float

    The size of the points in meters

  • opacity
    : float

    Decimal percentage of opacity

  • spherical
    : True or False

    If True, will assume the points are in [lon, lat, height] format (in degrees and meters)

Returns:

  • glyph

    The Mayavi Glyph object corresponding to the points

fatiando.vis.myv.polyprisms(prisms, prop=None, style='surface', opacity=1, edges=True, vmin=None, vmax=None, cmap='blue-red', color=None, linewidth=1, edgecolor=(0, 0, 0), scale=(1, 1, 1))[source]

Plot a list of 3D polygonal prisms using Mayavi2.

Will not plot a value None in prisms.

Parameters:

  • prisms
    : list of fatiando.mesher.PolygonalPrism

    The prisms

  • prop
    : str or None

    The physical property of the prisms to use as the color scale. If a prism doesn’t have prop, or if it is None, then it will not be plotted If prop is a vector (like magnetization), will use the intensity (norm).

  • style
    : str

    Either 'surface' for solid prisms or 'wireframe' for just the contour

  • opacity
    : float

    Decimal percentage of opacity

  • edges
    : True or False

    Wether or not to display the edges of the prisms in black lines. Will ignore this if style='wireframe'

  • vmin, vmax
    : float

    Min and max values for the color scale. If None will default to the min and max of prop in the prisms.

  • cmap
    : Mayavi colormap

    Color map to use. See the ‘Colors and Legends’ menu on the Mayavi2 GUI for valid color maps.

  • color
    : None or tuple = (r, g, b)

    If not None, then for all prisms to have this RGB color

  • linewidth
    : float

    The width of the lines (edges) of the prisms.

  • edgecolor
    : tuple = (r, g, b)

    RGB of the color of the edges. If style=’wireframe’, then will be ignored. Use parameter color instead

  • scale
    : (sx, sy, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

Returns:

  • surface

    the last element on the pipeline

fatiando.vis.myv.prisms(prisms, prop=None, style='surface', opacity=1, edges=True, vmin=None, vmax=None, cmap='blue-red', color=None, linewidth=1, edgecolor=(0, 0, 0), scale=(1, 1, 1))[source]

Plot a list of 3D right rectangular prisms using Mayavi2.

Will not plot a value None in prisms

Parameters:

  • prisms
    : list of fatiando.mesher.Prism

    The prisms

  • prop
    : str or None

    The physical property of the prisms to use as the color scale. If a prism doesn’t have prop, or if it is None, then it will not be plotted If prop is a vector (like magnetization), will use the intensity (norm).

  • style
    : str

    Either 'surface' for solid prisms or 'wireframe' for just the contour

  • opacity
    : float

    Decimal percentage of opacity

  • edges
    : True or False

    Wether or not to display the edges of the prisms in black lines. Will ignore this if style='wireframe'

  • vmin, vmax
    : float

    Min and max values for the color scale. If None will default to the min and max of prop in the prisms.

  • cmap
    : Mayavi colormap

    Color map to use. See the ‘Colors and Legends’ menu on the Mayavi2 GUI for valid color maps.

  • color
    : None or tuple = (r, g, b)

    If not None, then for all prisms to have this RGB color

  • linewidth
    : float

    The width of the lines (edges) of the prisms.

  • edgecolor
    : tuple = (r, g, b)

    RGB of the color of the edges. If style=’wireframe’, then will be ignored. Use parameter color instead

  • scale
    : (sx, sy, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

Returns:

  • surface

    the last element on the pipeline

fatiando.vis.myv.savefig(fname, magnification=None)[source]

Save a snapshot the current Mayavi figure to a file.

Parameters:

  • fname
    : str

    The name of the file. The format is deduced from the extension.

  • magnification
    : int or None

    If not None, then the scaling between the pixels on the screen, and the pixels in the file saved.

fatiando.vis.myv.show()[source]

Show the 3D plot of Mayavi2.

Enters a loop until the window is closed.

fatiando.vis.myv.tesseroids(tesseroids, prop=None, style='surface', opacity=1, edges=True, vmin=None, vmax=None, cmap='blue-red', color=None, linewidth=1, edgecolor=(0, 0, 0), scale=(1, 1, 1))[source]

Plot a list of tesseroids using Mayavi2.

Will not plot a value None in tesseroids

Parameters:

  • tesseroids
    : list of fatiando.mesher.Tesseroid

    The tesseroids

  • prop
    : str or None

    The physical property of the tesseroids to use as the color scale. If a tesseroid doesn’t have prop, or if it is None, then it will not be plotted. If prop is a vector (like magnetization), will use the intensity (norm).

  • style
    : str

    Either 'surface' for solid tesseroids or 'wireframe' for just the contour

  • opacity
    : float

    Decimal percentage of opacity

  • edges
    : True or False

    Wether or not to display the edges of the tesseroids in black lines. Will ignore this if style='wireframe'

  • vmin, vmax
    : float

    Min and max values for the color scale. If None will default to the min and max of prop.

  • cmap
    : Mayavi colormap

    Color map to use. See the ‘Colors and Legends’ menu on the Mayavi2 GUI for valid color maps.

  • color
    : None or tuple = (r, g, b)

    If not None, then for all tesseroids to have this RGB color

  • linewidth
    : float

    The width of the lines (edges) of the tesseroids.

  • edgecolor
    : tuple = (r, g, b)

    RGB of the color of the edges. If style=’wireframe’, then will be ignored. Use parameter color instead

  • scale
    : (slon, slat, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

Returns:

  • surface

    the last element on the pipeline

fatiando.vis.myv.title(text, color=(0, 0, 0), size=0.3, height=1)[source]

Draw a title on a Mayavi figure.

Warning

Must be called after you’ve plotted something (e.g., prisms) to the figure. This is a bug.

Parameters:

  • text
    : str

    The title

  • color
    : tuple = (r, g, b)

    RGB of the color of the text

  • size
    : float

    The size of the text

  • height
    : float

    The height where the title will be placed on the screen

fatiando.vis.myv.wall_bottom(bounds, color=(0, 0, 0), opacity=0.1, scale=(1, 1, 1))[source]

Draw a 3D wall in Mayavi2 on the Bottom side.

Note

Remember that x->North, y->East and z->Down

Parameters:

  • bounds
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    The extent of the region where the wall is placed

  • color
    : tuple = (r, g, b)

    RGB of the color of the wall

  • opacity
    : float

    Decimal percentage of opacity

  • scale
    : (slon, slat, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

fatiando.vis.myv.wall_east(bounds, color=(0, 0, 0), opacity=0.1, scale=(1, 1, 1))[source]

Draw a 3D wall in Mayavi2 on the East side.

Note

Remember that x->North, y->East and z->Down

Parameters:

  • bounds
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    The extent of the region where the wall is placed

  • color
    : tuple = (r, g, b)

    RGB of the color of the wall

  • opacity
    : float

    Decimal percentage of opacity

  • scale
    : (slon, slat, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

fatiando.vis.myv.wall_north(bounds, color=(0, 0, 0), opacity=0.1, scale=(1, 1, 1))[source]

Draw a 3D wall in Mayavi2 on the North side.

Note

Remember that x->North, y->East and z->Down

Parameters:

  • bounds
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    The extent of the region where the wall is placed

  • color
    : tuple = (r, g, b)

    RGB of the color of the wall

  • opacity
    : float

    Decimal percentage of opacity

  • scale
    : (slon, slat, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

fatiando.vis.myv.wall_south(bounds, color=(0, 0, 0), opacity=0.1, scale=(1, 1, 1))[source]

Draw a 3D wall in Mayavi2 on the South side.

Note

Remember that x->North, y->East and z->Down

Parameters:

  • bounds
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    The extent of the region where the wall is placed

  • color
    : tuple = (r, g, b)

    RGB of the color of the wall

  • opacity
    : float

    Decimal percentage of opacity

  • scale
    : (slon, slat, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

fatiando.vis.myv.wall_top(bounds, color=(0, 0, 0), opacity=0.1, scale=(1, 1, 1))[source]

Draw a 3D wall in Mayavi2 on the Top side.

Note

Remember that x->North, y->East and z->Down

Parameters:

  • bounds
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    The extent of the region where the wall is placed

  • color
    : tuple = (r, g, b)

    RGB of the color of the wall

  • opacity
    : float

    Decimal percentage of opacity

  • scale
    : (slon, slat, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others

fatiando.vis.myv.wall_west(bounds, color=(0, 0, 0), opacity=0.1, scale=(1, 1, 1))[source]

Draw a 3D wall in Mayavi2 on the West side.

Note

Remember that x->North, y->East and z->Down

Parameters:

  • bounds
    : list = [xmin, xmax, ymin, ymax, zmin, zmax]

    The extent of the region where the wall is placed

  • color
    : tuple = (r, g, b)

    RGB of the color of the wall

  • opacity
    : float

    Decimal percentage of opacity

  • scale
    : (slon, slat, sz)

    Scale factors used to exaggerate on a particular direction, e.g., if scale = (1, 1, 2), the vertical dimension will be 2x larger than the others