rrdtool y-axis values "200m" instead of "0.2" - graph

I've got a rrd which contains mostly values 0 to 1 (linux load avarage).
Sometimes the graph displays at the y-axis => "0.1 0.2 ... 0.9". That's the way I want it.
But other times, I see the following "100m 200m ...".
Is there a way to force displaying as "0.1 etc." values?

-X 0 did the trick.
[-X|--units-exponent value]
This sets the 10**exponent scaling of the y-axis values. Normally, values will be scaled to the appropriate units (k, M, etc.). However, you may wish to display units always in k (Kilo, 10e3) even if the data is in the M (Mega, 10e6) range, for instance. Value should be an integer which is a multiple of 3 between -18 and 18 inclusively. It is the exponent on the units you wish to use. For example, use 3 to display the y-axis values in k (Kilo, 10e3, thousands), use -6 to display the y-axis values in u (Micro, 10e-6, millionths). Use a value of 0 to prevent any scaling of the y-axis values.

Related

How to plot two files with error bars in gnuplot side by side?

I have two files with three columns. The first column is the X, the second column is the Y - Mean, and the third is the error.
I need to plot these two files to compare the error between them. I can plot but the error bars overlap. I need them to stand side by side.
Archive 1
10 0.15127 0.0986
30 0.14606 0.10022
60 0.16739 0.10298
Archive 2
10 0.19177 0.10253
30 0.17864 0.12178
60 0.18111 0.11272
What I can plot
What I need
I need the two categories to be side by side with the bar showing the error for plus and minus and midpoint.
We will use the line number (column 0, shorthand $0) for the x coordinate and offset the second set of values by 1/10 unit on x
set offset 0.5, 0.5 # put whitespace on both sides of the data
set yrange [0:1]
plot 'ar1' using ($0):2:3:xtic(1) with yerrrorbars, \
'ar2' using ($0+0.1):2:3 with yerrorbars

gnuplot with 2 x axis from data points

I have a data file, the data for y axis are in the third column. I would like to have the scale given by the first column on the x1 and by the second column on the x2. The standard way would be to:
plot data u 1:2 axes x1y1, data u 1:3 x2y1
But that creates two plots which is something I want to avoid. Of course one could make the above work with colours or with some other dirty tricks. It makes the whole plot code very cumbersome. Another nice way is to use multiplot as suggested here. But this is not really my goal, as I want to have the the real x2 axis.
Another way that came to my mind was to set x2range but that means going to the source file and figuring out the min and max or using some statistics in gnuplot (which feels like a waste of time for such a simple thing).
Is there any more simple and elegant way than the above ones? (I am especially concerned about the solution to be short to write, the plot can consist of several (>5) datasets and doing and I want to avoid plotting each dataset twice.
This can be done in this way, by telling gnuplot to re-scan file with 2nd column as x2 values but only invalid y-values for this second plot:
set xtics nomirror
set xrange [:] noextend
set x2tics
set x2range [:] noextend
plot '/tmp/f.gdat' u 1:3 w l, '' u 2:(1/0) ax x2y1
As an example, you can plot this data with Celsius on x and Fahrenheit on x2:
0 32 0
30 86 1
60 140 2
90 194 3
Note that this will only be sensible if column 2 is affinely linked with column 1. If you know the affine relation, using set link is much better.

Gnuplot histogram 3d

I'm looking for a way to plot histograms in 3d to produce something like this figure http://www.gnuplot.info/demo/surface1.17.png but where each series is a histogram.
I'm using the procedure given here https://stackoverflow.com/a/19596160 and http://www.gnuplotting.org/calculating-histograms/ to produce histograms, and it works perfectly in 2d.
Basically, the commands I use are
hist = 'u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart):(1) smooth freq w boxes
plot 'data.txt' #hist
Now I would just like to add multiple histograms in the same plot, but because they overlap in 2d, I would like to space them out in a 3d plot.
I have tried to do the following command (using above procedure)
hist = 'u (1):(binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart):(1) smooth freq w boxes
splot 'data.txt' #hist
But gnuplot complains that the z values are undefined.
I don't understand why this would not put a histogram along the value 1 on the x-axis with the bins along the y-axis, and plot the height on the z-axis.
My data is formatted simply in two columns:
Index angle
0 92.046
1 91.331
2 86.604
3 88.446
4 85.384
5 85.975
6 88.566
7 90.575
I have 10 files like this, and since the values in the files are close to each other, they will completely overlap if I plot them all in one 2d histogram. Therefore, I would like to see 10 histograms behind each other in a sort of 3d perspective.
This second answer is distinct from my first. Whereas the first addresses what the OP was trying to accomplish, this second provides an alternative approach which address the underlying problem the OP was trying to overcome.
I have posted an answer that addresses the ability to do this in 3d. However, this isn't usually the best way to do this with multiple histograms like this. A 3d graph like that will be difficult to compare.
We can address the overlap in 2D by stagnating the position of the boxes. With default settings, the boxes will spread out to touch. We can turn that off and adjust the position of the boxes to allow more than 1 histogram on a graph. Remember, that the coordinates you supply are the center of the boxes.
Suppose that I have the data you have provided and this additional data set
Index Angle
0 85.0804
1 92.2482
2 90.0384
3 99.2974
4 87.729
5 94.6049
6 86.703
7 97.9413
We can set the boxwidth to 2 units with set boxwidth 2 (your bins are 4 units wide). Additionally, we will turn on box filling with set style fill solid border lc black.
Then I can issue
plot datafile1 u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart):(1) smooth freq w boxes, \
datafile2 u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart+1):(1) smooth freq w boxes
The second plot command is identical to the first, except for the +1 after binstart. This will shift this box 1 unit to the right. This produces
Here, the two series are clear. Keeping track of which box is associated with each is easy because of the overlap, but it is not enough to mask the other series.
We can even move them next to each other, with no overlap, by subtracting 1 from the first plot command:
plot datafile1 u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart-1):(1) smooth freq w boxes, \
datafile2 u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart+1):(1) smooth freq w boxes
producing
This first answer is distinct from my second. This answer address what the OP was trying to accomplish whereas the second addresses the underlying problem the OP was trying to overcome.
Gnuplot isn't going to be able to do this on it's own, as the relevant styles (boxes and histograms) only work in 2D. You would have to do it using an external program.
For example, using your data and your 2d command (your first command), we get (using your data and the linked values of -100 and 4 for binstart and binwidth)
To draw these boxes on the 3d grid, we will need to use the line style and have four points for each: lower left, upper left, upper right, and lower right. We can use the previous command and capture to a table, but this will only gives the upper center point. We can use an external program to pre-process, however. The following python program, makehist.py, does just that.
from sys import argv
import re
from math import floor
pat = re.compile("\s+")
fname = argv[1]
binstart = float(argv[2])
binwidth = float(argv[3])
data = [tuple(map(float,pat.split(x.strip()))) for x in open(fname,"r").readlines()[1:]]
counts = {}
for x in data:
bn = binwidth*(floor((x[-1]-binstart)/binwidth)+0.5)+binstart
if not bn in counts: counts[bn] = 0
counts[bn]+=1
for x in sorted(counts.keys()):
count = counts[x]
print(x-binwidth/2,0)
print(x-binwidth/2,count)
print(x+binwidth/2,count)
print(x+binwidth/2,0)
print(max(counts.keys())+binwidth/2,0)
print(min(counts.keys())-binwidth/2,0)
Essentially, this program does the same thing as the smooth frequency option does, but instead of getting the upper center of each box, we get the four previously mentioned points along with two points to draw a line along the bottom of all the boxes.
Running the following command,
plot "< makehist.py data.txt -100 4" u 1:2 with lines
produces
which looks very similar to the original graph. We can use this in a 3d plot
splot "< makehist.py data.txt -100 4" u (1):1:2 with lines
which produces
This isn't all that pretty, but does lay the histogram out on a 3d plot. The same technique can be used to add multiple data files onto it spread out. For example, with the additional data
Index Angle
0 85.0804
1 92.2482
2 90.0384
3 99.2974
4 87.729
5 94.6049
6 86.703
7 97.9413
We can use
splot "< makehist.py data.txt -100 4" u (1):1:2 with lines, \
"< makehist.py data2.txt -100 4" u (2):1:2 with lines
to produce

plot more than one confidence interval in one plot at a particular order[SAS]

I need to plot more than one confidence interval in one plot at a particular order.
For example, my data is:
N Est. Lower Upper
1 5 3 6
2 1 0 4
3 3 0 7
I use the following command to plot:
proc sgplot data=confidence;
scatter y=N x=est. / xerrorlower=lower xerrorupper=upper
markerattrs=(symbol=circlefilled size=9);
run;
SAS will always plot the confidence interval at the order of N from 1 to 3. However, I need to show a trend of est. change. i.e the order I need is N=2 at first followed by N=3 and N=1 corresponding to est. = 1 3 5. Even after sorted by est., SAS still do the same things. I know I can sort and add an new order to my data to make the result I want, but I still want to show the correct N in my final plot to tell me the number of my confidence interval. Thanks.
You can request a discrete vertical axis, and specify the ordering method using the yaxis statement:
yaxis discreteorder = data type = discrete;
This will tell SAS to ignore the values in N and display them based on the order in which they are read from the dataset. You will have to sort your data in advance.

R Avoid x axis beeing automatically power of ten scaled

R automatically uses powers of ten for the x axis (values are from zero to 500000) - but i want just the plain figures in steps of 50000 or something (NOT written as powers of ten).
I tried to set the axis with axis(1,c(0,100000,....)) but it is plotted as powers of ten again.
I tried to scale down the font with cex.axis but it still uses power of ten for the x-axis. I think R tries to secure enough space between the values on the x-axis - but i want to force the full values to be plotted.
Axis looks at the moment like this:
-4e+05 -2e+05 0e+00 2e+05 4e+04 and so on ...
This link seems to answer your question: http://tolstoy.newcastle.edu.au/R/help/05/09/12499.html
e.g. option(scipen=6) would make the cutoff for scientific notation only for numbers larger than 1e6 I believe.

Resources