我有 2 个文本文件,每两列包含如下数字:
26 0.000342231
27 0.000342231
28 0.000684463
29 0.00136893
30 0.00102669
31 0.00308008
32 0.00308008
33 0.00444901
...
77 0.00102669
79 0.000684463
80 0.000342231
81 0.000342231
82 0.000684463
以及以下用于绘图的 python 代码:
import numpy as np
import matplotlib.pyplot as plt
import scipy, scipy.stats
plt.plotfile('histdata1.txt', delimiter=' ', cols=(0, 1), names=('stale block', 'frequency'), marker='o', markersize=5, c='r', alpha=0.5, linewidth=0, markeredgewidth=0, markeredgecolor='w')
plt.plotfile('histdata3.txt', delimiter=' ', cols=(0, 1), names=('stale block', 'frequency'), marker='o', markersize=5, c='g', alpha=0.5, linewidth=0, markeredgewidth=0, markeredgecolor='w')
plt.show()
这段代码在不同的图形上生成两个图 - 但是我想在同一个图形上显示两个图。我怎样才能实现这个目标?
最佳答案
将 newfig=False
添加到第二个 plt.plotfile()
参数集将阻止第二个图形绘制在不同的图形中。完整的例子可以在 here. 找到。
关于python - matplotlib.pyplot.plotfile() - 如何将多个图形绘制到同一个图形中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31988553/