[R] xlim with barplot
Jim Lemon
jim at bitwrit.com.au
Mon Sep 23 06:06:59 CEST 2013
On 09/23/2013 01:56 PM, arun wrote:
> You could try ggplot() as well.
> library(ggplot2)
> library(gridExtra)
> library(plyr)
> x1<- count(x)
> y1<- count(y)
> p1<-ggplot(x1,aes(x=x,y=freq))+geom_bar(stat="identity",colour="gray",fill="red")+xlim(c(35,85))+ theme_bw()+ theme(axis.line=element_line(colour="black"),
> panel.grid.major=element_blank(), panel.grid.minor=element_blank(), panel.border=element_blank(),panel.background=element_blank())
> p2<-ggplot(y1,aes(x=x,y=freq))+geom_bar(stat="identity",colour="gray",fill="blue")+xlim(c(35,85)) +theme_bw()+ theme(axis.line=element_line(colour="black"),
> panel.grid.major=element_blank(), panel.grid.minor=element_blank(),
> panel.border=element_blank(),panel.background=element_blank())
> grid.arrange(p1,p2,nrow=2)
>
> A.K.
>
Hi arun,
Okay, if we're allowed to use packages, challenge taken:
library(plotrix)
barp(tabulate(x,nbins=85)[35:85],names.arg=35:85)
barp(tabulate(y,nbins=85)[35:85],names.arg=35:85)
Jim
More information about the R-help
mailing list