示例#1
0
def test_plot_list():
    vtki.plot([sphere, sphere_b],
              off_screen=OFF_SCREEN,
              style='points')

    vtki.plot([sphere, sphere_b, sphere_c],
              off_screen=OFF_SCREEN,
              style='wireframe')
示例#2
0
def test_plot(tmpdir):
    filename = os.path.join(vtki.USER_DATA_PATH, 'tmp.png')
    scalars = np.arange(sphere.n_points)
    cpos, img = vtki.plot(sphere,
                          off_screen=OFF_SCREEN,
                          full_screen=True,
                          text='this is a sphere',
                          show_bounds=True,
                          color='r',
                          style='wireframe',
                          line_width=10,
                          scalars=scalars,
                          flip_scalars=True,
                          cmap='bwr',
                          interpolate_before_map=True,
                          screenshot=filename,
                          return_img=True)
    assert isinstance(cpos, list)
    assert isinstance(img, np.ndarray)
    assert os.path.isfile(filename)
    # remove file
    os.remove(filename)
示例#3
0
def test_plot(tmpdir):
    try:
        filename = str(tmpdir.mkdir("tmpdir").join('tmp.png'))
    except:
        filename = '/tmp/tmp.png'

    scalars = np.arange(sphere.n_points)
    cpos, img = vtki.plot(sphere,
                          off_screen=OFF_SCREEN,
                          full_screen=True,
                          text='this is a sphere',
                          show_bounds=True,
                          color='r',
                          style='wireframe',
                          linethick=10,
                          scalars=scalars,
                          flipscalars=True,
                          colormap='bwr',
                          interpolatebeforemap=True,
                          screenshot=filename)
    assert isinstance(cpos, list)
    assert isinstance(img, np.ndarray)
    assert os.path.isfile(filename)
示例#4
0
    def plot(self, **args):
        """
        Adds a vtk unstructured, structured, or polymesh to the plotting object

        Parameters
        ----------
        mesh : vtk unstructured, structured, or polymesh
            A vtk unstructured, structured, or polymesh to plot.

        color : string or 3 item list, optional, defaults to white
            Either a string, rgb list, or hex color string.  For example:
                color='white'
                color='w'
                color=[1, 1, 1]
                color='#FFFFFF'

            Color will be overridden when scalars are input.

        style : string, optional
            Visualization style of the vtk mesh.  One for the following:
                style='surface'
                style='wireframe'
                style='points'

            Defaults to 'surface'

        scalars : numpy array, optional
            Scalars used to "color" the mesh.  Accepts an array equal to the
            number of cells or the number of points in the mesh.  Array should
            be sized as a single vector.

        rng : 2 item list, optional
            Range of mapper for scalars.  Defaults to minimum and maximum of
            scalars array.  Example: [-1, 2]

        stitle : string, optional
            Scalar title.  By default there is no scalar legend bar.  Setting
            this creates the legend bar and adds a title to it.  To create a
            bar with no title, use an empty string (i.e. '').

        showedges : bool, optional
            Shows the edges of a mesh.  Does not apply to a wireframe
            representation.

        psize : float, optional
            Point size.  Applicable when style='points'.  Default 5.0

        opacity : float, optional
            Opacity of mesh.  Should be between 0 and 1.  Default 1.0

        linethick : float, optional
            Thickness of lines.  Only valid for wireframe and surface
            representations.  Default None.

        flipscalars : bool, optional
            Flip scalar display approach.  Default is red is minimum and blue
            is maximum.

        lighting : bool, optional
            Enable or disable Z direction lighting.  True by default.

        ncolors : int, optional
            Number of colors to use when displaying scalars.

        interpolatebeforemap : bool, default False
            Enabling makes for a smoother scalar display.  Default False

        screenshot : str, default None
            Takes a screenshot when window is closed when a filename is
            entered as this parameter.

        full_screen : bool, optional
            Opens window in full screen.  When enabled, ignores window_size.
            Default False.

        Returns
        -------
        cpos : list
            Camera position, focal point, and view up.

        Examples
        --------
        >>> # take screenshot without opening window
        >>> mesh.plot(off_screen=True, screenshot='mesh_picture.png')

        """
        return vtki.plot(self, **args)
def test_plot_invalid_style():
    with pytest.raises(Exception):
        vtki.plot(sphere, style='not a style')