Skip to content
Advertisement

Alternatives to Mayavi (Python 3.X) Linux

I’ve been trying to install and use Mayavi using Python 3.5 for almost a week. Unfortunately, I am not able to use it properly. At first, I struggled to install it along Python 3.5 version. Now, that I finally made it, the code simply doesn’t show the plot. It opens and closes the window instantly, and I think it may be some problem with the O.S. that I am using (Ubuntu 16.04).

(A code example:)

import numpy
from mayavi.mlab import *

def test_triangular_mesh():
    """An example of a cone, ie a non-regular mesh defined by its
        triangles.
    """
    n = 8
    t = numpy.linspace(-numpy.pi, numpy.pi, n)
    z = numpy.exp(1j * t)
    x = z.real.copy()
    y = z.imag.copy()
    z = numpy.zeros_like(x)

    triangles = [(0, i, i + 1) for i in range(1, n)]
    x = numpy.r_[0, x]
    y = numpy.r_[0, y]
    z = numpy.r_[1, z]
    t = numpy.r_[0, t]

    return triangular_mesh(x, y, z, triangles, scalars=t)


test_triangular_mesh()

I need Mayavi to plot 2D and 3D dynamic (== animated) finite element meshes in Python, and I thought Mayavi could be an alternative to Matplotlib, which also does not fit the purpose.

Is there any other option besides Mayavi and Matplotlib? Something that works with Python 3.5 (or even better: Python 3.6) and it is as easy to use as Mayavi was supposed to be?

Thank you all in advance,

Advertisement

Answer

You simply forgot to call

show()

at the end. The above code with show() added, produces this plot

(This is on windows, but it will be similar in Linux, given that everything is correctly installed.)

Advertisement