Using scale_x_continuous
with geom_histogram
always results in a false error regarding rows removed.
I believe this may be because a histogram is technically on a discrete axis, but the reason for the error still doesn't make sense. scale_x_discrete
does not produce the error, but does not manipulate the axis as easily either.
group<-rep(1:2,500)
df<-data.frame(group)
df$length<-group*0.75*(sample(200:800,1000,replace = T))
min(df$length)
max(df$length)
histogram <- ggplot(df, aes(x=length, fill = as.factor(group))) +
geom_histogram (aes(y=..count..), position = "identity", alpha = 0.6, binwidth = 10, colour="black") +
scale_y_continuous(limits=c(0,25),expand=c(0,0),breaks=c(0,25,5))+
scale_x_continuous (limits = c(100,1300),expand = c(0,0),breaks=seq(100,1300,100)) +
scale_fill_discrete () +
ylab("Count") + xlab("Length");histogram