단일 3D 분산 플롯에 여러 데이터 세트를 플로팅하는 데 문제가 있습니다. 제가하고있는 일은 제가 3 개의 방정식을 가지고 있고 linalg를 사용하여 방정식의 0을 계산하는 것입니다. 저는 3D 플롯 위에 놓인 0의 각 집합을 그려 봅니다. 내 매개 변수 중 하나는 값을 변경하고 0이 어떻게 변하는 지 관찰하는 것입니다. 하나의 3D 산점도에 모든 데이터 세트를 플롯하여 3D 그래프가 어떻게 다른지 쉽게 비교할 수 있지만 각 데이터 세트에 대해 하나의 그래프를 그려 볼 수 있습니다. 당신이 고칠 필요가있는 것을 알아낼 수 있습니까?3 차원 분산 형 플롯에서 다중 데이터 플롯
import numpy as np
from numpy import linalg
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
plt.close('all')
#Will be solving the following system of equations:
#sx-(b/r)z=0
#-x+ry+(s-b)z=0
#(1/r)x+y-z=0
r=50.0
b=17.0/4.0
s=[10.0,20.0,7.0,r/b]
color=['r','b','g','y']
markers=['s','o','^','d']
def system(s,b,r,color,m):
#first creates the matrix as an array so the parameters can be changed from outside
#and then coverts array into a matrix
u_arr=np.array([[s,0,-b/r],[-1,r,s-b],[1/r,1,-1]])
u_mat=np.matrix(u_arr)
U_mat=linalg.inv(u_mat)
#converts matrix into an array and then into a list to manipulate
x_zeros=np.array(U_mat[0]).reshape(-1).tolist()
y_zeros=np.array(U_mat[1]).reshape(-1).tolist()
z_zeros=np.array(U_mat[2]).reshape(-1).tolist()
zeros=[x_zeros,y_zeros,z_zeros]
coordinates=['x','y','z']
print('+'*70)
print('For s=%1.1f:' % s)
print('\n')
for i in range(3):
print('For the %s direction, the roots are: ' % coordinates[i])
for j in range(3):
print(zeros[i][j])
print('-'*50)
fig3d=plt.figure()
ax=Axes3D(fig3d)
ax.scatter(x_zeros,y_zeros,z_zeros,c=color,marker=m)
plt.title('Zeros for a Given System of Equations for s=%1.1f' % (s))
ax.set_xlabel('Zeros in x Direction')
ax.set_ylabel('Zeros in y Direction')
ax.set_zlabel('Zeros in z Direction')
plt.show()
for k in range(len(s)):
system(s[k],b,r,color[k],markers[k])
미리 도움을 청하십시오.