gnuplot y-axis format convert bytes to megabytes - gnuplot

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.

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):

Related

How to replace label values of y axis by an equivalent number in figure produced by Python-matplotlib?

The following figure is produced by python-matplotlib, I want to realize to two things:
1.Replace the original value of y axis by a new equivalent number, for example, -21e-5 replaced by -201e-6;
2.Change the font, font size and font style of the exponent.
P.s. The curve consists of many data points stored in a txt file(using ‘with open()’ syntax to get these data).

Gnuplot: change power ten prefixes

I have some plots where I have a logarithmic axis ranging from 10^-6 to 10^6. For this, I use the format
set format y '%0.0s\,%c'
which gives the nice power of ten prefixes like micro (u), milli (m), kilo (k) and so on. However, I don't like the 'u' for micro, but I would like to use a 'mu' instead. How can I do this?

gnuplot: Replace decimal point by another character

Using gnuplot v4.6.6:
To increase the available space for the actual graph I want to reduce the space required by the y-axis label to the bare minimum.
I'm now using: set format y "%4.1s%c".
Which results in labels like 500.0k. It would be nice if I could reduce this by one more character resulting in labels that look like this : 500k0
However, I can't figure out how to get this. Can it be done, and if so: how?
Thanks for your help.
EDIT: Here's an example graph of what I have now:
For this graph I use set format y "%3.0s%c" which is okay most of the time. But in some cases an extra decimal would be helpful.
You can modify the decimal character:
set decimalsign 'k'
Update:
Or you could plot log10(bits/s);
set yrange[0:9]
set ytics 1
plot 'data.d' using 1:(log10($2))
That would represent everything between 0 bits/s and 10^9 bits/s with a single digit on the y axis...

Turn Off Scientific Notation In Gnuplot

In gnuplot I've enabled logscale for my y axis, which gives me 1 to 1,000,000. However, the 1,000,000 tick appears in scientific notation. That stands out since its the only number in that form. I'd like to have it written as 1000000. All of my Google searches for disabling scientific notation, formatting as a decimal, or making the ytics space wider haven't produced anything that solves my problem.
The format of the axis tics is set either with set format x or set xtics format (equivalent commands for y, z, x2, y2 and cb exists as well).
Use show format to find out, which is the default format (result for 4.6.6, since 5.0 the default is % h)
gnuplot> show format
tic format is:
x-axis: "% g"
...
%g is a gnuplot-specific format specifier, but works similar to the C format specifiers used for sprintf and similar functions. The definition of %g according to the gnuplot documentation is: "the shorter of %e and %f". This is why the format can change for a single axis.
So, finally, to change to a fixed format for all tics, use e.g.
set format y '%.0f'

set gnuplot precision for a specific column

I have a data file with 3 columns and I'd like to plot a 2D map plot. What I do in gnuplot is:
p'datafile' u 1:2:3 with image
for some set of data, the data on the 3rd column (say Z) are different with order of 0.01, e.g 1.56, 1.58, 1.59 etc. I'd like to skip those small difference and consider them all 1.5. How can I set gnuplot to consider only up to one digit after decimal for 3rd column? Thanks!
You can use the floor function to round your numbers down:
plot 'datafile' using 1:2:(floor($3*1e1)/1e1) with image
This sets all your numbers to 1 decimal place. If you wanted to do the same thing for a higher number of decimal places, you could change the 1e1 to 1eN, where N is the number of decimal places you want.

Resources