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. please help me to solve my query....gurus. Thank you Jeet [[alternative HTML version deleted]]
Hi r-help-bounces at r-project.org napsal dne 01.06.2010 13:01:38:> Dear All, > > I am newbie to R, and I wanted to plot a barplots with R and in such away> 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 mark10.2> and on other also.I do not understand what you want? What is 10.2 maybe names.arg is what you want. barplot (chromosome, col="purple", xlab="Oryza sativa Chromosomes", border = NA, space = 5, ylim = c(0,45), names.arg=chromosome, axes=F)> I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45i.e> gap of 5 instead of 10.use axes=F and axis(2, at=seq(0,45,5)) Regards Petr> > please help me to solve my query....gurus. > > > Thank you > Jeet > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Hi, If you want to draw lines on your barchart then aa = barplot(chromosome, col="purple", xlab="Oryza sativa Chromosomes", border = NA, space = 5, ylim = c(0,45)) returns the midpoints of each bar in the vector aa and then you can use the lines() function to do the drawing. Martyn -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of khush ........ Sent: 01 June 2010 12:02 To: r-help at r-project.org Subject: [R] Help barplots 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. please help me to solve my query....gurus. Thank you Jeet [[alternative HTML version deleted]] ______________________________________________ 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. ________________________________________________________________________ This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}
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. > > please help me to solve my query....gurus. >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) # add the y-axis: 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 >
On 06/01/2010 09:01 PM, 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. > > please help me to solve my query....gurus. >Hi Jeet, I think you want the x positions of the bars. Get them like this: xpos<-barplot (chromosome, col="purple", xlab="Oryza sativa Chromosomes", border = NA, space = 5, ylim = c(0,45)) Then you can place the extra labels using the values in xpos. For the custom y axis, add the argument yaxt="n" to your plot command and then add the axis later. I suspect you will have to use something like the staxlab function in the plotrix package to get all those labels to display. Jim
Hi all, I want to draw a arrow (small) of any length along with OsCYP right side i.e parrallel and antiparallel arrows both text(os[1], 10.2, pos = 4, "OsCYP", font=1, cex = 1, col = "red") and how can I connect two points with dotted line lets say bp[1 ]10.2 ---------------------------------------- bp[3], 15.2 how to make a dotted line using R, is it possible Thank you in advance Jeet On Tue, Jun 1, 2010 at 4:31 PM, khush ........ <bioinfo.khush@gmail.com>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. > > please help me to solve my query....gurus. > > > Thank you > Jeet >[[alternative HTML version deleted]]