gnuplot stdin, how to plot two lines?

前端 未结 9 1481
栀梦
栀梦 2020-12-09 08:13

I\'m trying to produce a plot with two lines using data taken from stdin. I have a file \"test.csv\":

0,1.1,2
1,2,3
2,6,4
4,4.6,5
5,5,6

I\

相关标签:
9条回答
  • 2020-12-09 09:02

    I managed to work around this by sending the data twice, terminated by am "e" on it's own line after each block. So your input should look like

    set datafile separator ","; plot '-' using 1:2 with lines, '' using 1:3 with lines
    0,1.1,2
    1,2,3
    2,6,4
    4,4.6,5
    5,5,6
    e
    0,1.1,2
    1,2,3
    2,6,4
    4,4.6,5
    5,5,6
    e
    
    0 讨论(0)
  • 2020-12-09 09:07

    Maybe this is an old question but I've found an interesting solution based on the other answers:

    cat filename | awk -- '{print $0} END{print "e"}' | tee -i -a - -
    

    The output would be:

    "contents of filename"
    e
    "contents of filename"
    e
    "contents of filename"
    e
    

    Now cat and awk work as usual, the utility tee on the other hand allows us to copy the standard output piped from the previous command to a file, but this file can be stdin itself so we can make many copies of it, by specifying n times - after -a.

    The option -i stops it being interrupted by signals during the copy, -a tells it to append the input to standard input without overwriting and then write the whole thing to stdout.

    For reference take a look at Tee Utility

    0 讨论(0)
  • 2020-12-09 09:07

    For me this works when I do:

    set datafile separator ','
    plot "test.csv" using 1:2 with lines
    

    it seems that you used "," for datafile separator instead of ','

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