0
votes

In gnuplot, how do you plot flattened tables that fit the form of aggregated key-value pairs? For example given this tab-delimited file, how could I plot a bar graph for type=foo, with one bar per version?

type    version count
foo a   1
foo b   2
foo c   3
bar a   3
bar b   2
bar c   1
baz a   0
baz b   2
baz c   2

Extra credit: How would I plot k subplots, one for each type (e.g. foo, bar, and baz?

1
Yes, I did, thanks. I see how you can do two columns. Not sure how to expand that to extra columns. - Nick Ruiz

1 Answers

0
votes

Use awk inside of gnuplot. First, filter the table for only 'foo' rows, then generate an x cordinate with $NF var. Pass this edited file to plot (note the quotes around the awk command) with the with boxes option:

 plot "< gawk '$1 ~ /foo/ {print $NF, $2, $3 }' table.dat " using 1:3:xtic(2) with boxes

You can add multiple plots to a single diagram in gnuplot, so you could run the command above changing the filter to add "bar" and "baz" curves.