python - How to create graph where a geometry be surrounded by particles using Matplotlib? -


using examples , documentation matplotlib, can create 1 figure 2 graphs this. on left, geometry graph , on right, particles graph. want create graph geometry surrounded particles. how that?

here code far:

from mpl_toolkits.mplot3d import axes3d matplotlib import cm import matplotlib.pyplot plt import numpy np  fig = plt.figure()  vx = [] vy = [] vz = [] ins = open( "vertex.txt", "r" ) line in ins:     nilai = line.strip().split()     vx.append(float(nilai[1]))     vy.append(float(nilai[2]))     vz.append(float(nilai[3]))  triangles = [] ins = open( "iface4.txt", "r" ) line in ins:     nilai = line.strip().split()     t1 = int(nilai[1])     t2 = int(nilai[2])     t3 = int(nilai[3])     if t1!=0 , t2!=0 , t3!=0:         triangles.append([t1, t2, t3])  ax = fig.add_subplot(121, projection='3d') #ax = fig.gca(projection='3d') ax.plot_trisurf(vx, vy, vz, triangles=triangles, cmap=cm.jet, linewidth=0.2)  vx = [] vy = [] vz = [] ins = open( "particle.txt", "r" ) line in ins:     nilai = line.strip().split()     vx.append(float(nilai[0]))     vy.append(float(nilai[1]))     vz.append(float(nilai[2]))  ax = fig.add_subplot(122, projection='3d') ax.scatter(vx, vy, vz, c='b', marker='o')  plt.show() 

i think brenbarn correct, if remove line:

ax = fig.add_subplot(122, projection='3d') 

then particle scatter plot on same axis. you're reusing variable name 'ax' in code, confusing you.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -