You are creating a new axes instance each time system()
is called. Instead pass ax
as an argument to system
def system(s,b,r,color,m, ax):
# ...
ax.scatter(x_zeros,y_zeros,z_zeros,c=color,marker=m)
Then create the axes instance before looping
fig3d=plt.figure()
ax=Axes3D(fig3d)
for k in range(len(s)):
system(s[k],b,r,color[k],markers[k], ax)
plt.show()
This was all plots are added to ax
. You may then want to think about setting the axes labels etc outside of the system()
function. Splitting it into two functions, one which sets the plot up and one which creates the required data and plots it.