graph.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:pyqus 作者: JorgeDeLosSantos 项目源码 文件源码
def plot_elements(figname="elements.png",nodesfile="nodes.txt",elementsfile="elements.txt",dlm=","):
    """
    Plot nodes and elements of mesh.

    Parameters
    ----------
    figname      : str
        Name of output picture
    nodesfile    : str
        Path of node data file
    elementsfile : str
        Path of elements conectivity file
    dlm          : str
        Delimiter (i.e. ",","\t")
    """
    NC = np.loadtxt(nodesfile, delimiter=dlm)
    EC = np.loadtxt(elementsfile, delimiter=dlm)
    f = plt.figure()
    ax = f.add_subplot(111)
    plt.hold(True)
    for element in EC:
        XX = []
        for node in element:
            if str(node)!="nan":
                XX.append([NC[node-1,0],NC[node-1,1]])
        p = Polygon(XX, True, fc="#00DDDD", ec="#778877")
        ax.add_patch(p)
    plt.axis('equal')
    plt.axis('off')
    plt.savefig(figname)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号