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)
评论列表
文章目录