Thanks for your response. I just have two more questions:
1) I don't know how to write the titles of the LR and Q behind their
lines of values (at the bottom of the graph). I tried to write like
text = sprintf("LR%.1f", LR)...
but it writes 'LR' behind all values while I only want it once at the
beginning of the line while all the LR and Q values are still in the mid
points of bars.
2) I would like a line which connects the mid points of each bar to be
like a density function (or regression) line which is not sharp like what I
have now. I tried to write density in the code but it tells "Error in
xy.coords(x, y) : 'x' and 'y' lengths differ"
I appreciate any comment about these questions
Thanks,
Mohsen
On 10/2/06, Marc Schwartz (via MN) <[EMAIL PROTECTED]> wrote:
>
> 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,
> > Mohsen
>
>
> I'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
>
>
>
--
Mohsen Jafarikia
Department of Animal and Poultry Science
University of Guelph
Phone: (519) 824-4120 ext.58353
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.