绘制美观的图像,主要靠积累,直接上代码:

 

import matplotlib.pyplot as plt
import numpy as np

# generate x values
x = np.random.randn(1000)

# random measurements, no correlation
y1 = np.random.randn(len(x))

# strong correlation
y2 = 1.2 + np.exp(x)

plt.figure(figsize=(16,9))
ax1 = plt.subplot(121)
plt.scatter(x, y1, color='indigo', alpha=0.9, edgecolors='white', label='no correl')
plt.xlabel('no correlation')
plt.grid(True)
plt.legend()

ax2 = plt.subplot(122, sharey=ax1, sharex=ax1)
plt.scatter(x, y2, color='green', alpha=0.3, edgecolors='grey', label='correl')
plt.xlabel('strong correlation')
plt.grid(True)
plt.legend()

plt.show()

plt.scatter函数案例一则

相关文章:

  • 2022-12-23
  • 2021-10-25
  • 2021-09-19
  • 2022-02-25
  • 2023-04-10
  • 2021-11-10
  • 2022-02-24
  • 2022-12-23
猜你喜欢
  • 2022-01-14
  • 2021-04-25
  • 2021-04-01
  • 2021-10-27
  • 2023-04-10
  • 2021-05-04
  • 2022-12-23
相关资源
相似解决方案