# 3D plot and its 2D projection for two classes

I am unable to plot 3D plot from the points in 3 dimension properly using scipy multivariate_normal and matplotlib.Attaching the question and the code I wrote:

Question:

Create samples in 3 dimensions(d1,d2,d3) from two normal distributions (corresponding to two classes).Plot their projections in 2D(in all possible pairs of dimensions d1-d2, d2-d3 and d1-d3 ) and also a 3D plot.

1. Two random mean , covariance is diagonal
2. Two random means , covariance being general Positive semi definite 3.Two identical means , but different covariances

Code

import numpy as np

from mpl_toolkits import mplot3d import matplotlib.pyplot as plt from scipy.stats import multivariate_normal

mean2 = [10, 5, -3] cov2 = [[1,0,0], [0,20,0], [0,0,100]] x2, y2, z2 = np.random.multivariate_normal(mean2, cov2, 500).T x3, y3 = np.meshgrid(x2, y2) z3 = np.tile(z2, (500, 1))

mean4 = [50, 2, 1] cov4 = [[100,0,0], [0,20,0], [0,0,10]] x4, y4, z4 = np.random.multivariate_normal(mean4, cov4, 500).T x5, y5 = np.meshgrid(x4, y4) z5 = np.tile(z4, (500, 1))

fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_surface(x3, y3, z3) ax.plot_surface(x5, y5, z5) fig.show()