In [1]:
# Note that this notebook does require a number of dependencies.
# pytmatgen is used for the high-level interface to the Materials Project.
# The excellent prettyplotlib is used to make nice plots.
# prettytable is used to make nice ASCII tables.
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d.axes3d import Axes3D
%matplotlib inline
In [2]:
def make_plots(T):
max_x = np.sqrt(abs(T[2] / T[0]))
max_y = np.sqrt(abs(T[2] / T[1]))
x = np.linspace(-3*max_x, 3*max_x, 500)
y = np.linspace(-3*max_y, 3*max_y, 500)
X, Y = np.meshgrid(x, y)
Z = (1 - T[0]* X ** 2 + - T[1]* Y ** 2) / T[2]
fig = plt.figure(figsize=(16,12))
ax = fig.add_subplot(2, 2, 1, projection='3d')
ax.set_title("3D representation")
ax.set_xlabel("X")
ax.set_xlabel("Y")
ax.set_zlabel("Z")
#Do projections (using polar coordinates)
theta = np.linspace(-np.pi, np.pi, 1001)
p = ax.plot_wireframe(X, Y, np.sqrt(Z), rstride=4, cstride=4)
p = ax.plot_wireframe(X, Y, -np.sqrt(Z), rstride=4, cstride=4)
ax = fig.add_subplot(2, 2, 2, polar=True)
r = np.sqrt(1 / (T[0] * np.cos(theta) ** 2 + T[1] * np.sin(theta) ** 2))
ax.plot(theta, r, color='r', linewidth=3)
ax.set_title("x-y plane")
ax.set_rmax(max(1.1, np.nanmax(r) / 5))
ax = fig.add_subplot(2, 2, 3, polar=True)
r = np.sqrt(1 / (T[1] * np.cos(theta) ** 2 + T[2] * np.sin(theta) ** 2))
ax.plot(theta, r, color='r', linewidth=3)
ax.set_title("y-z plane")
ax.set_rmax(max(1.1, np.nanmax(r) / 5))
ax = fig.add_subplot(2, 2, 4, polar=True)
theta = np.linspace(0, 2 * np.pi, 5000)
r = np.sqrt(1 / (T[0] * np.cos(theta) ** 2 + T[2] * np.sin(theta) ** 2))
ax.plot(theta, r, color='r', linewidth=3)
ax.set_title("x-z plane")
ax.grid(True)
ax.set_rmax(max(1.1, np.nanmax(r) / 5))
In [3]:
make_plots([1.1, 1.5, 1.7])
In [4]:
make_plots([-0.5, 1, 1])
In [5]:
make_plots([-0.5, -0.7, 1])
In [ ]: