Python matplotlib.pyplot 模块,triplot() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用matplotlib.pyplot.triplot()

项目:nanopores    作者:mitschabaude    | 项目源码 | 文件源码
def fem2contour(u):
    mesh = u.function_space().mesh()
    v2d = dolfin.vertex_to_dof_map(u.function_space())

    # extract x and y coordinates of nodes
    x = mesh.coordinates()[:,0]
    y = mesh.coordinates()[:,1]
    triangles = mesh.cells()

    # Create triangulation.
    triang = mtri.Triangulation(x, y, triangles)

    # create array of node values from function
    z = u.vector()[v2d]

    # Plot the triangulation.
    plt.figure()
    plt.tricontourf(triang, z)
    #plt.triplot(triang, 'k-')
    #plt.title('Triangular grid')
项目:PyBGMM    作者:junlulocky    | 项目源码 | 文件源码
def plot_points(X, barycentric=True, border=True, **kwargs):
    '''Plots a set of points in the simplex.
    Arguments:
        `X` (ndarray): A 2xN array (if in Cartesian coords) or 3xN array
                       (if in barycentric coords) of points to plot.
        `barycentric` (bool): Indicates if `X` is in barycentric coords.
        `border` (bool): If True, the simplex border is drawn.
        kwargs: Keyword args passed on to `plt.plot`.
    '''
    if barycentric is True:
        X = X.dot(corners)
    plt.plot(X[:, 0], X[:, 1], 'k.', ms=1, **kwargs)
    plt.axis('equal')
    plt.xlim(0, 1)
    plt.ylim(0, 0.75**0.5)
    plt.axis('off')
    if border is True:
        plt.hold(1)
        plt.triplot(triangle, linewidth=1)
项目:smeshing    作者:bast    | 项目源码 | 文件源码
def generate_plot(points, triangles, out_file_name):
    import matplotlib.pyplot as plt

    # remove triangles outside bounds
    # not sure how they can appear
    _triangles = []
    for triple in triangles:
        keep_triangle = True
        for t in triple:
            if not -1 < t < len(points):
                keep_triangle = False
        if keep_triangle:
                _triangles.append(triple)

    x, y = zip(*points)

    plt.figure()
    plt.gca().set_aspect('equal')
    plt.triplot(x, y, _triangles, 'g-', markersize=0.2, linewidth=0.2)
    plt.savefig(out_file_name, dpi=300)
项目:hippylib    作者:hippylib    | 项目源码 | 文件源码
def plot(obj, colorbar=True, subplot_loc=None, mytitle=None, show_axis='off', vmin=None, vmax=None, logscale=False):
    if subplot_loc is not None:
        plt.subplot(subplot_loc)
#    plt.gca().set_aspect('equal')
    if isinstance(obj, dl.Function):
        pp = mplot_function(obj, vmin, vmax, logscale)
    elif isinstance(obj, dl.CellFunctionSizet):
        pp = mplot_cellfunction(obj)
    elif isinstance(obj, dl.CellFunctionDouble):
        pp = mplot_cellfunction(obj)
    elif isinstance(obj, dl.CellFunctionInt):
        pp = mplot_cellfunction(obj)
    elif isinstance(obj, dl.Mesh):
        if (obj.geometry().dim() != 2):
            raise AttributeError('Mesh must be 2D')
        pp = plt.triplot(mesh2triang(obj), color='#808080')
        colorbar = False
    else:
        raise AttributeError('Failed to plot %s'%type(obj))

    plt.axis(show_axis)

    if colorbar:
        plt.colorbar(pp, fraction=.1, pad=0.2)
    else:
        plt.gca().set_aspect('equal')

    if mytitle is not None:
        plt.title(mytitle, fontsize=20)

    return pp
项目:FaceRecognition    作者:fonfonx    | 项目源码 | 文件源码
def delaunay_triangulation(points, plot=False):
    """ Extract a Delaunay's triangulation from the points """
    tri = Delaunay(points)
    if plot:
        plt.triplot(points[:, 0], points[:, 1], tri.simplices.copy())
        plt.plot(points[:, 0], points[:, 1], 'o')
        plt.show()
    return tri.simplices