[R] Re: Bar plot with variable width (down a drill hole) - now missing intervals?
Phillip J. Allen
paallen at attglobal.net
Tue Mar 25 22:48:55 CET 2003
Hi again,
Thanks Ted and Marc its works. But of course after pulling in in some
real life data I discoverd one hitch. Often there are missing
intervals. For example:
from <- c(0, 1.2, 4.0, 4.2, 5.0, 25.0, 30.1, 45)
to <- c(1.2, 4.0, 4.2, 5.0, 25, 30.1, 36.2, 50)
intensity <- c(0, 1, 3, 2, 1, 0, 2, 5)
barplot(intensity, width = -(to - from),
space = 0, horiz = TRUE, ylim = c(-40, 0))
And it appears a barplot() is just stacking bars one on top the other
and the help page doesn't indicate anyway to position the bar along the
y-axis. So does anyone have a nifty trick to to fill in blank gaps? At
least my database can check for "overlaping" intervals before I get the
data into R.
Thanks,
Phillip J. Allen
Consulting Geochemist/Geologist
Lima Peru
e-mail: paallen at attglobal.net
Phillip,
How about this, which will generate a vertical barplot, a y axis from 0
down to 40 meters and bar widths and colors for each segment varied:
from <- c(0, 1.2, 4.0, 4.2, 5.0, 25.0, 30.1)
to <- c(1.2, 4.0, 4.2, 5.0, 25, 30.1, 36.2)
intensity <- c(0, 1, 3, 2, 1, 0, 2)
barplot(intensity, width = -(to - from),
space = 0, horiz = TRUE, ylim = c(-40, 0))
axis(2, las = 2, labels = c(40, 30, 20, 10, 0))
mtext(side = 2, text = "Hole Depth (m)", line = 3)
Hope that helps,
Marc Schwartz
**********************************************
It looks as though it should do: see in particular the
arguments height, width, and space, to the function
as described in help(barplot).
For example:
x0<-c(0, 1.2, 4.0, 4.2, 5.0, 25.0, 30.1)
x1<-c(1.2, 4.0, 4.2, 5.0, 25.0, 30.1, 36.2)
y<-c(0, 1, 3, 2, 1, 0, 2)
w<-x1-x0
y[y==0]<-0.001
barplot(height=y,width=w,space=0)
(the extra 0.001 gives a thickened baseline where y=0, to
avoid the impression that there is no bar at such points)
Ted.
******************************
original message
Hi all,
I am trying to make a bar plot of observations along a line or
specifically a drill hole with the bars widths representing the interval
of the observation and the length of the bar the actual data. My data
is in the following format:
from(m) to(m) Intensity of silicification
0 1.2 0
1.2 4.0 1
4.0 4.2 3
4.2 5.0 2
5.0 25 1
25.0 30.1 0
30.1 36.2 2
......
Is the barplot() function what I really want to use?
Thanks for any help.
Phillip J. Allen
Consulting Geochemist/Geologist
Lima Peru
e-mail: paallen at attglobal.net
More information about the R-help
mailing list