Hello,
I have used the following data to draw my barplot:
BL LR Q
36.35 1.00 1.92
36.91 4.00 0.00
25.70 6.00 0.00
34.38 3.00 1.92
05.32 0.50 0.00
BL<-c(36.35, 36.91, 25.70, 34.38, 05.32)
LR<-c(1.00, 4.00, 6.00, 3.00, 0.50)
Q<-<(1.92, 0.00, 0.00, 1.92, 0.00)
barplot(dt$LR, main='LR Value', col='orange',
border='black', space=0.05,
width=(dt$BL), xlab='Length', ylab='LR')
axis(1)
I would like to do the following things that I don't know how to do it:
1) Writing the value of each 'BL' on my X axis.
2) Writing the value of 'Q' on the bottom of X axis.
3) Draw a line on the bars which connects the 'LR' values.
I appreciate your comments.
Thanks,
Mohsen
[[alternative HTML version deleted]]
On Mon, 2006-10-02 at 11:14 -0400, Mohsen Jafarikia wrote:> Hello, > > I have used the following data to draw my barplot: > > BL LR Q > > 36.35 1.00 1.92 > 36.91 4.00 0.00 > 25.70 6.00 0.00 > 34.38 3.00 1.92 > 05.32 0.50 0.00 > > BL<-c(36.35, 36.91, 25.70, 34.38, 05.32) > LR<-c(1.00, 4.00, 6.00, 3.00, 0.50) > Q<-<(1.92, 0.00, 0.00, 1.92, 0.00) > > barplot(dt$LR, main='LR Value', col='orange', border='black', space=0.05, > width=(dt$BL), xlab='Length', ylab='LR') > > axis(1) > > I would like to do the following things that I don't know how to do it: > > 1) Writing the value of each 'BL' on my X axis. > 2) Writing the value of 'Q' on the bottom of X axis. > 3) Draw a line on the bars which connects the 'LR' values. > > I appreciate your comments. > > Thanks, > MohsenI'm not sure if I am getting this completely correct, but is this what you want? BL <- c(36.35, 36.91, 25.70, 34.38, 5.32) LR <- c(1.00, 4.00, 6.00, 3.00, 0.50) Q <- c(1.92, 0.00, 0.00, 1.92, 0.00) # Get the bar midpoints in 'mp' mp <- barplot(LR, main='LR Value', col='orange', border='black', space=0.05, width=(BL), xlab='Length', ylab='LR') # Write the LR and Q values below the bar midpoints mtext(1, at = mp, text = sprintf("%.1f", LR), line = 1) mtext(1, at = mp, text = sprintf("%.1f", Q), line = 0) # Now connect the LR values across the bars lines(mp, LR) See ?barplot, ?mtext, ?sprintf and ?lines HTH, Marc Schwartz
Hello everyone,
I have the following program to draw a barplot.
MP<-read.table(file='AR.out')
names(MP)<-c('BN','BL','LR','Q')
Graph<- barplot(MP$LR, main='LR Value', col='orange',
border='black', space0.05, width=(MP$BL), xlab='Length',
ylab='LR each')
axis(1, at=Graph, sprintf('%0.2f',MP$BL))
mtext(1, at=Graph, text=sprintf('%0.2f',MP$Q), line=2)
mtext(1, at=par('usr')[1], text='BL', line=1)
mtext(1, at=par('usr')[1], text='Var', line=2)
abline(h=3.841,col='blue')
abline(h=6.635,col='red')
I have two more questions about the graph that I have:
1) I want to write the 'Q' only when it is not equal to zero.
2) I would like to change the bars when 'Q' is not zero. For example,
from
orange to green.
I would appreciate your input to this question.
Thanks,
Mohsen
[[alternative HTML version deleted]]
Hello everyone:
I am using the following code to draw my barplot but it has two problems.
BL<-c(1.97,8.04,2.54,10.53,4.85,1.73)
LR<-c(0.85,0.86,8.33,04.18,6.26,2.40)
Q<-c(0.00,0.00,1.92,01.92,4.48,0.00)
cols <- ifelse(Q!=0, "orange", "green")
Graph<- barplot(LR, main='LR Value',col=cols, border='black',
space=0.05,
width=(BL), xlab='Length', ylab='LR block',mar=c(5,1,4,2))
<<<<<<<<<
axis(1, at=Graph, sprintf('%0.2f',BL))
mtext(1, at=Graph, text=ifelse(Q!=0, sprintf('%0.2f',Q), ""),
line=2)
mtext(1, at=par('usr')[1], text='BL', line=1)
mtext(1, at=par('usr')[1], text='Var', line=2)
abline(h=3.84,col='blue')
abline(h=6.64,col='red')
text(31,3.84,expression(paste(alpha==5,"%")),pos=3)
<<<<<
text(31,6.64,expression(paste(alpha==1,"%")),pos=3)
<<<<<
1) I don't know how to specify the margins. I have written it in the
code but it is not working.
2) I want the value of alph=5% at the right end of the line but it is
almost in the left side and sometimes in the right side when I use the same
code for drawing another barplot.
I appreciate any comments about these problems.
Thanks,
Mohsen
[[alternative HTML version deleted]]
Hi, I have about 500 data entry ranging from -50 to 10,000. when I barplot(data), it plots all 500 of them individually. How can I set a ranges to group these 500 numbers into 10 or 20 groups, and plot the value of the ranges with how many numbers are in the range. Thanks a lot, Q.
Qian Wan wrote:> Hi, > > I have about 500 data entry ranging from -50 to 10,000. when I > barplot(data), it plots all 500 of them individually. How can I set a > ranges to group these 500 numbers into 10 or 20 groups, and plot the > value of the ranges with how many numbers are in the range.Maybe something along these lines: Y <- c(-50, 10000, sample(-50:10000, size=498, replace=TRUE)) par(mar = c(8, 5, 5, 5)) X <- barplot(table(cut(Y, breaks=c(-50, seq(0, 10000, 1000)), include.lowest=TRUE)), xaxt = "n", xlab = "") text(X, -2, srt = 45, adj = 1, labels = levels(cut(Y, breaks=c(-50, seq(0, 10000, 1000)), include.lowest=TRUE)), xpd = TRUE) ?cut for more details on forming the groups. Also, have you considered hist() ?> Thanks a lot, > > Q. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894