How to treat the first line of the data file as column labels in gnuplot?

倖福魔咒の 提交于 2019-12-20 17:25:53

问题


I have a table like this:

A B C D E F G H I 
10 23998 16755 27656 17659 19708 20328 19377 18925
20 37298 33368 53936 41421 44548 40756 40985 37294

I use this command to plot

plot "C:/file.txt" using 1:2 with lines smooth bezier, "C:/file.txt" using 1:3 with lines smooth bezier, ...

However, all the labels come out as the file name. Is it possible for gnuplot to read the first row and label the lines accordingly?


回答1:


set key autotitle columnhead



回答2:


plot for [n=2:12] 'vv.csv' u 1:(column(n)) w lines title columnhead(n)

I didn't want to plot the first column of data hence n=2:.....




回答3:


I checked the documentation and I don't see a way to do it automatically, but you can manually set a title with

plot "file.txt" using 1:2 title "A" with lines smooth bezier ...



回答4:


I once wrote a script to plot FM radio station frequencies along an axis from 87MHz to 108MHz, using the names of each radio station as vertical labels. This was not a pure gnuplot solution, the input file is processed with perl with make, but I suggest you have a look at it and see if you can use something like that.




回答5:


You could also use a gnuplot toolkit such as this one for Python if you want have a lot of data to plot and you want to automate the extraction of the titles.



来源:https://stackoverflow.com/questions/773643/how-to-treat-the-first-line-of-the-data-file-as-column-labels-in-gnuplot

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