Это код:
%matplotlib widget
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d as plt3d
import matplotlib.animation as animation
fig = plt.figure(dpi=50)
fig.canvas.layout.width = '500px' ; fig.canvas.layout.height = '500px' ;
fig.subplots_adjust(top=1, bottom=0, left=0.0, right=1)
ax = fig.add_subplot(projection='3d')
#ax = plt.gca(projection='3d') ;
ax._axis3don = False
ax.view_init(azim=160,elev=15)
ax.dist =8
#text = fig.text(0, 1, "TEXT", va='top') # for debugging
#plot the nodes
for i in range(0, 1, 1) : # NODI
ax.scatter(nodi[:,1], nodi[:,3], nodi[:,2], color='black', marker='.')
#fig.show() ;
for i in range(0, np.size(eleP,0), 1) : # PILASTRI
xs = [nodi[eleP[i,1]-1,1],nodi[eleP[i,2]-1,1]]
ys = [nodi[eleP[i,1]-1,3],nodi[eleP[i,2]-1,3]]
zs = [nodi[eleP[i,1]-1,2],nodi[eleP[i,2]-1,2]]
frame = ax.add_line(plt3d.art3d.Line3D(xs, ys, zs))
for i in range(0, np.size(eleT,0), 1) : # TRAVI
xs = [nodi[eleT[i,1]-1,1],nodi[eleT[i,2]-1,1]]
ys = [nodi[eleT[i,1]-1,3],nodi[eleT[i,2]-1,3]]
zs = [nodi[eleT[i,1]-1,2],nodi[eleT[i,2]-1,2]]
frame = ax.add_line(plt3d.art3d.Line3D(xs, ys, zs))
def animate(ts):
text.set_text("{:d}: [{:.0f},{:.0f},{:.0f}]".format(ts)) # for debugging
for i in range(0, np.size(eleP,0), 1) : # PILASTRI
xs = [Tenso_Nodi[eleP[i,1]-1,1,ts],Tenso_Nodi[eleP[i,2]-1,1,ts]]
ys = [Tenso_Nodi[eleP[i,1]-1,3,ts],Tenso_Nodi[eleP[i,2]-1,3,ts]]
zs = [Tenso_Nodi[eleP[i,1]-1,2,ts],Tenso_Nodi[eleP[i,2]-1,2,ts]]
ax.add_line(plt3d.art3d.Line3D(xs, ys, zs))
for i in range(0, np.size(eleT,0), 1) : # TRAVI
xs = [Tenso_Nodi[eleT[i,1,ts]-1,1],Tenso_Nodi[eleT[i,2]-1,1,ts]]
ys = [Tenso_Nodi[eleT[i,1,ts]-1,3],Tenso_Nodi[eleT[i,2]-1,3,ts]]
zs = [Tenso_Nodi[eleT[i,1,ts]-1,2],Tenso_Nodi[eleT[i,2]-1,2,ts]]
ax.add_line(plt3d.art3d.Line3D(xs, ys, zs))
return ax,
ani = animation.FuncAnimation(fig, animate, 25, fargs=(i, xs,ys,zs,ax,ts),interval=500, blit=True)
ani
#plt.show()
Я использую трехмерный тензор с этим измерением: (строка = узлы; столбец = 3 направления disp (x, y, z); 3-dim = disp для1 кадр).
Не хочу ничего анимировать и не возвращать никаких ошибок.
Как это исправить?