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'
Related
I can't seem to get gnuplot to properly plot my time data. (I'm using version 4.6, patchlevel 3.)
For an MWE (well, non-working...), the input file
reset
set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%S"
plot '-' using ($1):($2) with lines lw 3
15:36:12 1.0
15:43:17 3.0
16:12:02 2.0
e
produces the following output:
Apparently, gnuplot interprets the hours as seconds and ignores the rest. I have tried a bunch of other format strings (also single/double quotes), but gnuplot seems to ignore everything except the first number.
Is something wrong with my format, or is this a bug, or something else?
With $1 you explicitely select the numerical value of the first column, which bypasses any gnuplot automatism to interpret the column values as appropriate (as time value in your case). Simply use using 1:2:
reset
set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%S"
plot '-' using 1:2 with lines lw 3
15:36:12 1.0
15:43:17 3.0
16:12:02 2.0
e
Use the syntax $1 only when doing calculations with the actual numerical value in the respective column. $1 is a shortcut for column(1), gnuplot also knows stringcolumn(1) and timecolumn(1) for other purposes.
I have a plot with exponential y axis range. I'm using multiplot command by inserting two images in one row. So due to this wide y axis range I'm loosing some space which I could use it to show my plots in a better way. I want basically something like this
How could i do this? I think for doing this I have do some math operations in the y axis range. Also what is the most convenient command to insert ( xE-10) at top left of the plot.
reset
set terminal epslatex size 16cm,18cm color colortext
set output new.tex
set key off
set format $%g$
set title "sinx"
set ylabel "[kNm]"
plot 1000000*sin(x)
This is not my exact code but it looks similar to this. The plot I have presented is a part of the multiplot code and I use 7 input files with time series data of 300 seconds at a time step of 0.02. The point I want to edit the y axis range (use some mathtematical expressions) and also include the term ( xE-10 ) on the top of the plot something like this
You can manually add the exponent with a set label .... For instance, the following function takes large values within the given interval:
plot[0:50] exp(x)
We can place the "x 10^21" manually in the desired place after dividing the plotted quantity by it:
set label 1 "{/Symbol \264} 10^{21}" at graph 0,1.025 left
plot[0:50] exp(x)/1e21
You have to be careful with the exact placement of the exponent since it might lie outside the plotting area, in which case you should lower the top margin with set tmargin .... Also, to use the "times" symbol, you need to pass the enhanced option to your terminal. With the epslatex terminal, you can use latex syntax: $\times 10^{21}$.
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...
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):
I'm plottng monetary data with gnuplot and currently I've managed to set the labels on the y axis to be floating point values with no decimals (rather than exponentials) but I want to be able to add comma's to the label but I cant figure out how.
Any ideas?
i.e. The current output gives me £25000000 - as you can see, the data isn't grouped - I want to split it in thousands so it appears as £25,000,000.
EDIT:
My current setting is
set format y '£%.0f'
As stated here the thousands separator depends on the locale-specific formatting.
If this setting allows for the thousands separator it will be printed with:
set decimal locale
set format y "%'g"
plot 1000*x
An other option would be to set the ytics manually (see here) like so:
set ytics ("5,000,000" 5000000, "10,000,000" 10000000, "15,000,000" 15000000, "20,000,000" 20000000, "25,000,000" 25000000)
plot[0:3] 10000000*x