Created
July 22, 2019 23:03
-
-
Save MinaGabriel/0a707b377de60392a8ef0cae87e14205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
from matplotlib.ticker import LinearLocator, FormatStrFormatter | |
import numpy as np | |
from scipy.stats import norm | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') | |
# Make data. | |
X = np.arange(0.01, 5, 0.1) | |
Y = np.arange(0.01, 5, 0.1) | |
X, Y = np.meshgrid(X, Y) | |
Z = norm(X, Y).pdf(5) | |
# Plot the surface. | |
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, alpha=0.4, | |
linewidth=0.2, antialiased=False) | |
ax.plot((4.91, 4.91), (0, 5), (0, 0), 'r') | |
ax.plot((0, 5), (0.11, 0.11), (0, 0), 'r') | |
# Customize the z axis. | |
ax.set_zlim(0, 2.8) | |
ax.zaxis.set_major_locator(LinearLocator(5)) | |
ax.view_init(40, 30) | |
ax.set_xlabel('$\mu$') | |
ax.set_ylabel('$\sigma$') | |
ax.set_zlabel('$p(5 | \mu, \sigma)$') | |
# Add a color bar which maps values to colors. | |
fig.colorbar(surf, shrink=0.5, aspect=5) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment