gnuplot - Make a histogram with data located in multiple files

心已入冬 提交于 2020-01-17 12:39:07

问题


I know how to make a histogram in gnuplot, but all the instructions I've seen are valid when the data is located in a single file. My problem is that my data spans several files. Is there any way to do this with gnuplot?


回答1:


Not really. Gnuplot is really only good at dealing with one file at a time. However, there are many useful external tools which could combine the files together for you:

plot "<magic_external_tool file1 file2 file3 file4 ..."  ...

of course your choice of external tool is a question of how your files are formatted already. If the standbys (awk, sed, join, cat ...) don't work, I often rely on python to write a quick script to do the job, but I'm sure many other people would use something like perl or java. It really doesn't matter what tool you use, as long as you can coax it to write a properly formatted file to standard output, you're golden.




回答2:


As mgilson says, this isn't really possible in gnuplot.

One thing you might want to consider (and I'm biased here as I'm an author of the project) is Pyxplot http://www.pyxplot.org.uk, which was written by a group of gnuplot users who were frustrated with problems like this. Like gnuplot, it's free and open source, and it's syntax is virtually identical.

For your needs, it has a histogram command, which produces a mathematical function representing a histogram computed from supplied data (see http://pyxplot.org.uk/current/doc/html/sec-histogram.html). You can do something along the lines of:

histogram f1() 'file1.dat'
histogram f2() 'file1.dat'
histogram f3() 'file1.dat'
plot f1(x) + f2(x) + f3(x)



回答3:


It seems to me that you can indeed do this using just Gnuplot, I just did it. The solution I used can be found here: https://stackoverflow.com/a/11092650/448700



来源:https://stackoverflow.com/questions/12082670/gnuplot-make-a-histogram-with-data-located-in-multiple-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!