当前位置:   article > 正文

matplotlib画图一行三个图_plt画三幅图

plt画三幅图

三图共轴

import numpy as np
import matplotlib.pyplot as plt

# Data for plotting
x1 = np.linspace(0.0, 5.0)
x2 = np.linspace(0.0, 2.0)
x3 = np.linspace(0.0, 1.0)
y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
y2 = np.cos(2 * np.pi * x2)
y3 = np.cos(np.pi * x3)

# Create three subplots sharing x axis
fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3)  # sharex=False, sharey=False
# Create three subplots sharing y axis
# fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, ncols=1)   
ax1.plot(x1, y1, 'ko-')
ax1.set(title='A tale of 3 subplots', xlabel='K', ylabel='Distance')

ax2.plot(x2, y2, 'r.-')
ax2.set(xlabel='K', ylabel='Local Clustering')
ax2.plot(x3, y3, 'r.-')

ax3.plot(x3, y3, 'r.-')
ax3.set(xlabel='K', ylabel='Average')

plt.show()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/612740
推荐阅读
相关标签
  

闽ICP备14008679号