Phillip J. Allen
2003-Mar-25 16:56 UTC
[R] Bar plot with variable width (down a drill hole)?
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
On 25-Mar-03 Phillip J. Allen wrote:> 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?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. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 25-Mar-03 Time: 18:01:05 ------------------------------ XFMail ------------------------------
Phillip J. Allen wrote:> 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.netPhillip, 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