How to plot ratios of values with Gnuplot

Last updated on June 14, 2020 by Dan Nanni

Gnuplot is a tool that can generate script-driven graphics, including plots of functions and data samples. Gnuplot contains a useful scripting language that allows you to process raw data files while producing graphics. For example, you can plot ratios of different values contained in raw data files.

If you would like to plot the ratio of data belonging to two different columns in a data file:

$ cat my.txt
1     10    20
2     20    25
. . .
plot "my.txt" using 1:($3/$2) title "ratio of the 3rd col over the 2nd col" with lp

If you would like to plot the ratio of data belonging to two different data files:

$ cat A.txt
1 10
2 20
. . .
$ cat B.txt
1 11
2 30
. . .
plot "< join A.txt B.txt" using 1:($3/$2) "ratio of data in B.txt over data in A.txt" lp

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean