我有数据文件,比如data.txt
as
1 10
2 20
3 30
4 41
5 49
1 11
2 19
3 32
4 37
5 52
注意有两组数据。我想把它们画在同一张图上。在gnuplot
中,非常简单,我们只需运行plot 'data.txt' with line
就可以得到这样的图,
实际上我在同一个数据文件中有50个这样的集合。我刚开始学习python
。我想用numpy
和matplotlib
来绘制这个数据文件。在
在这个论坛里也有类似的帖子
How to plot data from multiple two column text files with legends in Matplotlib?
How can you plot data from a .txt file using matplotlib?
但我找不到与我的问题类似的东西。在
一种方法是读取完整的文件,在出现双换行符的位置将其拆分,
.split('\n\n')
,并使用numpy.loadtxt
读取每个部分。在相关问题 更多 >
编程相关推荐