def _latvec_plot(self, R=True, withpts=False, legend=False):
"""Plots the lattice vectors (for real or reciprocal space).
"""
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
vecs = self.R if R else self.K
for i in range(3):
steps = np.linspace(0, 1, np.floor(10*np.linalg.norm(vecs[:,i])))
Ri = vecs[:,i]
Ri.shape = (1, 3)
steps.shape = (len(steps), 1)
line = np.dot(steps, Ri)
ax.plot(line[:,0], line[:,1], line[:,2], label="R{0:d}".format(i+1))
if withpts:
pts = self.r if R else self.G
ax.scatter(pts[:,0], pts[:,1], pts[:,2], color='k')
if legend:
ax.legend()
return (fig, ax)
评论列表
文章目录