I have the following code and along plots it generates. My aim is to plot on the second figure (right) a 1D Gaussian Distribution on the red plane shown.
The aim of this is to show that the overlap (which represents the conditional) is a Gaussian Distribution. I am not interested in the exact variance of the distribution to be correct but just show this visually.
Is there any straightforward way to do this in python?
Thanks, P
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.mlab import bivariate_normal
from mpl_toolkits.mplot3d import Axes3D
#Make a 3D plot
fig = plt.figure(figsize=plt.figaspect(0.5))
################ First Plot ##############
#Parameters to set
mu_x = 0
sigma_x = np.sqrt(5)
mu_y = 0
sigma_y = np.sqrt(5)
#Create grid and multivariate normal
x = np.linspace(-10,10,500)
y = np.linspace(-10,10,500)
X, Y = np.meshgrid(x,y)
Z = bivariate_normal(X,Y,sigma_x,sigma_y,mu_x,mu_y)
# Create plane
x_p = 2
y_p = np.linspace(-10,10,500)
z_p = np.linspace(0,0.02,500)
Y_p, Z_p = np.meshgrid(y_p, z_p)
# ax = fig.gca(projection='3d')
ax = fig.add_subplot(1,2,1, projection='3d')
ax.plot_surface(X, Y, Z, cmap='viridis',linewidth=0)
ax.plot_surface(x_p, Y_p, Z_p, color='r',linewidth=0, alpha=0.5)
plt.tight_layout()
################ Second Plot ##############
x_p = 2
y_p = np.linspace(-10,10,500)
z_p = np.linspace(0,0.02,500)
Y_p, Z_p = np.meshgrid(y_p, z_p)
# ax2 = fig.gca(projection='3d')
ax2 = fig.add_subplot(1,2,2,projection='3d')
ax2.plot_surface(x_p, Y_p, Z_p, color='r',linewidth=0, alpha=0.3)
plt.show()