How to use one of the column of data as legend in gnuplot?

前端 未结 1 1798
孤城傲影
孤城傲影 2021-01-21 10:23

I have data something like this:

# c1 c2 c3
23 b 323
23 g 54
23 a 11
23 c 1
23 d 0
23 e 397
23 f 40
24 b 23
24 g 24
24 a 113
24 c 12
24 d 10
24 e 7
24 f 50


        
相关标签:
1条回答
  • 2021-01-21 10:42

    In general, you must do the filtering outside of gnuplot, in order to have lines connecting the filtered points.

    If you know all values which can appear in the second column, you can use the solution given in Plotting multiple graphs depending on column value with gnuplot.

    If you don't know the possible values, you can extract them with

    c2s = system("awk '!/^#/ { print $2 }' test.dat | sort | uniq")
    

    and then plot them with

    plot for [c2 in c2s] sprintf('< grep ''\b%s\b'' test.dat', c2) using 1:3 with lines title c2
    

    enter image description here

    0 讨论(0)
提交回复
热议问题