a=data.frame(obs=rnorm(10))
p=ggplot(
data = a
,aes(
x = obs
)
)+geom_histogram(
)
p
p+scale_x_continuous(
limits = range(a$obs)
)
One fix is to explicitly set a binwidth then modify the limits accordingly:
my_binwidth = 1
p=ggplot(
data = a
,aes(
x = obs
)
)+geom_histogram(
bindwidth=my_binwidth
)
p+scale_x_continuous(
limits = c(min(a$obs)-binwidth,max(a$obs)+binwidth)
)
But this seems rather inelegant. Any suggestions?
--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
Looking to arrange a meeting? Check my public calendar:
http://tinyurl.com/mikes-public-calendar
~ Certainty is folly... I think. ~
Instead of using facet_grid, use facet_wrap(~ bin, drop = FALSE, nrow = 1)
Hadley
Here is the link to the output:
http://n2.nabble.com/extra-empty-panel-example-in-ggplot2-0.8.3-td2562582.html
Here is the code used to produce it:
setwd("/RStuff/ggplot2buildstuff/plyr/")
source("load.r")
setwd("/RStuff/ggplot2buildstuff/ggplot2/")
source("load.r")
Warning message:
package 'ggplot2' was built under R version 2.8.1
VADeaths_flat_df = stack(as.data.frame(VADeaths))
names(VADeaths_flat_df) = c('Data','Person')
max_range<-100
counts <- ddply(VADeaths_flat_df, .(cut(Data, breaks=fullseq(range(c(Data, max_range)), 20)), Person), nrow)
names(counts) <- c("bin", "person", "n")
print(qplot(person, n, data = counts, fill = person, geom="bar", stat="identity", width = 0.9) + facet_wrap(~ bin, drop = FALSE, nrow = 1) + opts(axis.text.x = NULL) + opts(axis.text.y = theme_text(colour = "red")) + opts(strip.text.x = theme_text(colour = "green", size=14)))
Theme element axis.text.x missing
Theme element axis.text.x missing
Theme element axis.text.x missing
Theme element axis.text.x missing
Theme element axis.text.x missing
--- On Mon, 3/30/09, hadley wickham <h.wi...@gmail.com> wrote:
> From: hadley wickham <h.wi...@gmail.com>
> Subject: Re: extra empty panel example in ggplot2 0.8.3
> To: jasonk...@yahoo.com
> Cc: "ggp...@googlegroups.com" <ggp...@googlegroups.com>, "Mike Lawrence" <Mike.L...@dal.ca>