Search code examples
cgnuplot

gnuplot from file with multiple metrics


I have a C program that writes three files with the first column being the X values (clock cycles). The other columns are a set of metrics like % of memory usage, memory "holes", etc. Like I said before, there are three files like this (one per algorithm: first fit, best fit and worst fit).

Example - Headers: Clock Cycle, % Memory Usage and Number of "holes":

File 1 (First Fit):

1 20% 5
2 30% 9
3 70% 12
4 90% 3

File 2 (Best Fit):

1 15% 3
2 20% 5
3 80% 7
4 40% 3
5 60% 9

File 3 (Worst Fit):

1 15% 3
2 20% 5
3 80% 7

I would like to know if there is a way with gnuplot to generate one graph per metric comparing the three algorithms in those metrics.

By the way, sorry about my english, hope you guys understand.


Solution

  • set term pngcairo size 600,400
    
    set output 'memory.png'
    plot 'file1' using 1:2 w lp, \
    'file2' using 1:2 w lp, \
    'file3' using 1:2 w lp
    
    set output 'holes.png'
    plot 'file1' using 1:3 w lp, \
    'file2' using 1:3 w lp, \
    'file3' using 1:3 w lp
    
    .......
    

    (it would be better if you get rid of '%' in second column)