Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- plt.style.use("ggplot")
- #np.random.seed(42)
- mean = [2, 3]
- cov = [[1, 1], [1, 2]]
- space = 0.2
- abscissa, ordinates = np.random.multivariate_normal(mean, cov, size=1000).T
- figure = plt.figure(figsize=(8, 8))
- grid = plt.GridSpec(4, 4, wspace=space, hspace=space)
- axis_scatter = figure.add_subplot(grid[:-1, 1:])
- axis_hist_vert = figure.add_subplot(
- grid[:-1, 0],
- sharey=axis_scatter,
- )
- axis_hist_hor = figure.add_subplot(
- grid[-1, 1:],
- sharex=axis_scatter,
- )
- axis_scatter.scatter(abscissa, ordinates, color="cornflowerblue", alpha=0.5)
- axis_hist_hor.hist(
- abscissa,
- bins=50,
- color="cornflowerblue",
- density=True,
- alpha=0.5,
- )
- axis_hist_vert.hist(
- ordinates,
- bins=50,
- color="cornflowerblue",
- orientation="horizontal",
- density=True,
- alpha=0.5,
- )
- axis_hist_hor.invert_yaxis()
- axis_hist_vert.invert_xaxis()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement