I am trying to store x,y,z points in a database based on conditions. These conditions come from the NACL structure. For example when x is even and y and z are odd, there is an NA atom - that coordinate will be stored as an NA atom. So when I search for where all the NA atoms are, I get a list of coordinates. Another thread asks a similar question where the answer is based around using np.where, but I'm not sure how to implement that in this.
My attempt is in the following code:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
#dimension/shape of grid and array
n = int (input("Enter CUBE dimension: "))
def cube(ax, n):
#Creating Arrays
parameter = np.arange(0,n,1)
xx, yy, zz = np.meshgrid(parameter, parameter, parameter)
valuesrange = np.zeros((n,n,n))
#list of arrays
a = [(xx,yy,zz)]
# my attempt at the problem
# if xx % 2 == 0 and yy % 2 != 0 and zz % 2 !=0:
# NA = [(xx,yy,zz)]
# elif xx % 2 != 0 and yy % 2 != 0 and zz % 2 ==0:
# NA = [(xx,yy,zz)]
# Etc...
print (a)
scatterplot = ax.scatter(xx, yy, zz, c = valuesrange, cmap=plt.cm.spectral_r, vmin=0, vmax=1,edgecolor = 'black', alpha = .7)
return scatterplot
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
scatterplot1 = cube(ax,n)
plt.colorbar(scatterplot1)
plt.show()
Any help is greatly appreciated!