Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot y-axis format convert bytes to megabytes

Using OpenTSDB we are capturing the number of bytes sent over the network interface per second. When graphing these figures the Y axis has scientific notation (i.e. 5e+07). The help text for the y-axis format option suggests that it can be used to convert bytes to megabytes or gigabytes - and refers to the Format Specifiers section of the GNU Plot documentation. I've read that but its still not clear to me how to convert the values. I could not find any examples where people had done the conversation by setting the Y axis format.

like image 620
user3642765 Avatar asked Aug 04 '14 16:08

user3642765


1 Answers

The format specifier %c gives you the character replacement of the respective scientific power, e.g. k for 1e3, M for 1e6 etc. The specifier %s sets the corresponding mantissa.

Consider the following file test.dat:

1e7
2e7
5e7
1e8

With the script

set format y '%.0s%cB'
plot 'test.dat' with linespoints

you get the output (using 4.6.5):

enter image description here

like image 159
Christoph Avatar answered Sep 22 '22 00:09

Christoph