How to creating scatterplots with left and bottom histograms just like in the sample below in ggplot2?
library(ggplot2)
library(gridExtra)
data1<-diamonds
detrend<-lm(log(price)~log(carat),data=data1)
data1$lprice2<-resid(detrend)
empty <- ggplot()+geom_point(aes(1,1), colour="white")+
opts(axis.ticks=theme_blank(),
panel.background=theme_blank(),
axis.text.x=theme_blank(), axis.text.y=theme_blank(),
axis.title.x=theme_blank(), axis.title.y=theme_blank())
scatter<-qplot(log(carat),lprice2,data=data1,xlab="Weight",ylab="Price Residuals",
colour=factor(color),main="Diamonds - Weight to Price by Color")
scatter<-scatter+theme(legend.position="top")
scatter<-scatter+theme(plot.title=element_text(size=20,colour="blue"))
hist_left<-ggplot(data1,aes(x=price, fill=color))+geom_histogram(aes(y = ..density..))+
theme(legend.position = "none")+coord_flip()
hist_bottom<-ggplot(data1,aes(x=carat, fill=color))+geom_histogram()
+theme(legend.position = "none")
How to use grid.arrange to arrange these plot and how to flip the hist_left like the picture?