Advertisement
Korotkodul

draw1

Mar 21st, 2025
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. plt.style.use("ggplot")
  4. #np.random.seed(42)
  5. mean = [2, 3]
  6. cov = [[1, 1], [1, 2]]
  7. space = 0.2
  8.  
  9. abscissa, ordinates = np.random.multivariate_normal(mean, cov, size=1000).T
  10. figure = plt.figure(figsize=(8, 8))
  11. grid = plt.GridSpec(4, 4, wspace=space, hspace=space)
  12.  
  13. axis_scatter = figure.add_subplot(grid[:-1, 1:])
  14. axis_hist_vert = figure.add_subplot(
  15.     grid[:-1, 0],
  16.     sharey=axis_scatter,
  17. )
  18. axis_hist_hor = figure.add_subplot(
  19.     grid[-1, 1:],
  20.     sharex=axis_scatter,
  21. )
  22. axis_scatter.scatter(abscissa, ordinates, color="cornflowerblue", alpha=0.5)
  23. axis_hist_hor.hist(
  24.     abscissa,
  25.     bins=50,
  26.     color="cornflowerblue",
  27.     density=True,
  28.     alpha=0.5,
  29. )
  30. axis_hist_vert.hist(
  31.     ordinates,
  32.     bins=50,
  33.     color="cornflowerblue",
  34.     orientation="horizontal",
  35.     density=True,
  36.     alpha=0.5,
  37. )
  38. axis_hist_hor.invert_yaxis()
  39. axis_hist_vert.invert_xaxis()
  40. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement