[R] y axis in a stacked bar plot

Jim Lemon drjimlemon at gmail.com
Thu Mar 26 10:27:29 CET 2015


Hi Michy,
I agree with Jeff that you probably don't want a stacked bar chart. What
you describe appears to be a display of relative positions of genetic
elements in different strains of mice and the place to ask is most likely
the Bioconductor mailing list.

Jim


On Thu, Mar 26, 2015 at 3:51 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
wrote:

> I don't understand what you expect. Stacked bar charts add the values
> together. Perhaps that is not really how you want to represent these data?
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
> Go...
>                                       Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> On March 25, 2015 9:29:40 PM PDT, Michelle Simon <M.Simon at har.mrc.ac.uk>
> wrote:
> >Hello,
> >Below is some simple R code I have used to create a stacked bar chart.
> >However the y-axis tick marks do not reflect the data.  The minimum and
> >maximum data values I have are 3073351 and 25329814 respectively but
> >the graph has data from 0 and the maximum is different  The data file
> >is too large so there is a small sample below.  What am I doing wrong?
> >Please help as I cannot be sure the data is represented correctly in
> >the graph (attached).
> >
> >fn <-"~/Documents/chr7Data.txt"
> >x<-read.table(fn,check.names = TRUE, header=T)
> >d <- data.frame(x)
> >theChart<-ggplot(d, aes(x=factor(Congenic),y=Position, fill=Strain,
> >theme_rect="white")) + geom_bar(stat='identity', position = "stack" ) +
> >scale_fill_manual(values=c("deepskyblue1", "red2", "green3",
> >"steelblue4", "lightblue4", "gray70")) + ylab(c("Position"))+
> >ggtitle("Strain specific SNP distribution in the congenics") +
> >
> >#coord_cartesian(ylim = c(min(d$Position), max(d$Position))) +
> >#scale_y_continuous(breaks=seq(0, 200000000, 50000000)) +
> >theme_bw()+
> >theme(plot.title = element_text(size=23),
> >           axis.text.x = element_text(size=13, angle=90),    #20 before
> >                axis.text.y = element_text(size=13),
> >                panel.border = element_rect(colour="BLACK",size=0.5),
> >                axis.title.x = element_text(size=12),
> >                axis.title.y = element_text(size=12,angle = 90),
> >                panel.background = element_rect(fill="transparent"),
> >                legend.text=element_text(size=13),
> >                legend.title=element_text(size=12)
> >      #plot.background = element_rect(fill = "transparent",colour = NA)
> >)
> >png("~/Documents/sendToRGrp.png",950,750)
> >print(theChart)
> >dev.off()
> >
> >——————————— Sample Data —————————————
> >Congenic Position Strain
> >4201 3073351 hets
> >4203 3073351 reference
> >4215 3073351 reference
> >4333 3073351 cba
> >4335 3073351 cba
> >4484 3073351 cba
> >4485 3073351 reference
> >4496 3073351 hets
> >4497 3073351 reference
> >//lots of data//
> >4201 25329814 reference
> >4203 25329814 reference
> >4215 25329814 cba
> >4333 25329814 balbc
> >4335 25329814 balbc
> >4484 25329814 reference
> >4485 25329814 reference
> >4496 25329814 balbc
> >4497 25329814 hets
> >
> >Many thanks,
> >Michy
> >
> >
> >This email may have a PROTECTIVE MARKING, for an explanation please
> >see:
> >
> http://www.mrc.ac.uk/About/Informationandstandards/Documentmarking/index.htm
> >
> >
> >------------------------------------------------------------------------
> >
> >______________________________________________
> >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >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.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

	[[alternative HTML version deleted]]



More information about the R-help mailing list