1

How we can visualize a Gaussian distribution without any line on the shape itself (a smooth plot).

The shape I want:

enter image description here

The shape I got so far:

enter image description here

Here is my code:

import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import multivariate_normal

# Parameters to set
mu_x = 0
variance_x = 5

mu_y = 0
variance_y = 5

# Create grid and multivariate normal
x = np.linspace(-10, 10, 500)
y = np.linspace(-10, 10, 500)
X, Y = np.meshgrid(x, y)
pos = np.empty(X.shape + (2,))
pos[:, :, 0] = X
pos[:, :, 1] = Y
rv = multivariate_normal([mu_x, mu_y], [[variance_x, 0], [0, variance_y]])

# Make a 3D plot

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_surface(X, Y, rv.pdf(pos), cmap='magma')

plt.axis('off')
# ax.view_init(90, 90)
plt.draw()
plt.savefig('test5.png', transparent=True)
plt.show()
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.