# Re: [R] Help barplots

From: Peter Ehlers <ehlers_at_ucalgary.ca>
Date: Tue, 01 Jun 2010 05:59:38 -0600

On 2010-06-01 5:01, khush ........ wrote:
> Dear All,
>
> I am newbie to R, and I wanted to plot a barplots with R and in such a way
> that It will also show me position which I can plot on the bar line.
>
> Here is my code that I am using to plot,
>
>> chromosome<- c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23, 23,
> 28.2)
>> barplot (chromosome, col="purple", xlab="Oryza sativa Chromosomes", border
> = NA, space = 5, ylim = c(0,45))
>
> I wanted to mark the position say on chromosome 1 (40.2) I need to mark 10.2
> and on other also.
> I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45 i.e
> gap of 5 instead of 10.
>
>

If I understand correctly, maybe you want something like this:

```# save the x-locations of the bars in a vector bp;
# use that to put marks on the bars with points();
# omit the default y-axis with yaxt = "n" or, as Petr
# showed, with axes = FALSE;

bp <- barplot(chromosome, border = NA, space = 5,
ylim = c(0, 45), yaxt = "n")
```
points(bp[1], 10.2, pch = 4, cex = 2)

axis(2, at = seq(0, 45, 5), las = 1)

#(you might want to add: box(bty = "l")

Instead of points(), you could use segments() to place horizontal marks.

-Peter Ehlers

>
> Thank you
> Jeet
>

R-help_at_r-project.org 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. Received on Tue 01 Jun 2010 - 12:04:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Jun 2010 - 13:10:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.