Gnuplot: Plot row-wise and named data as bundle of differently colored and titled lines

后端 未结 1 576
难免孤独
难免孤独 2021-01-15 05:30

I\'m trying to plot a bundle of graphs that are currently stored like this:

MyFile.txt

\"ID01\" 1 2 3 4 5
\"ID02\" 3 4 5 6 7 8 9
\"I         


        
1条回答
  •  孤城傲影
    2021-01-15 06:19

    This is not the way gnuplot uses to save data. Your approach has also other problems, i.e. you don't actually have a matrix if the rows have different number of points etc. The gnuplot way of handling such data would be to separate points belonging to different lines with two blank lines, and add the respective header before:

    "ID01"
    1
    2
    3
    4
    5
    
    
    "ID02"
    3
    4
    5
    6
    7
    8
    9
    
    
    "ID03"
    4
    3
    1
    2
    3
    4
    

    And then plot the data with

    set key autotitle columnheader left
    plot for [i=0:2] 'MyFile.txt' using 0:1 index i with linespoints
    

    Alternatively, if you prefer a more compact representation, you can save each line in a column. But then you must make sure, that shorter columns are filled up with empty values. For that one should use e.g. comma as field separators:

    "ID01","ID02","ID03"
    1,3,4
    2,4,3
    3,5,1
    4,6,2
    5,7,3
     ,8,4
     ,9,
    

    and plot with

    set key autotitle columnheader
    set datafile separator ','
    plot for [i=1:3] 'MyFile.csv' using 0:i with linespoints
    

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