I have the following R
code:
x<-runif(1000,0,33)
df1 <- data.frame(x)
df2<-data.frame(x=c(180,660))
df<-rbind(df1,df2)
eigenv<-c(runif(998,0,60),173,653)
df_rug <- data.frame(eigenv)
df$mask<-0
df$mask[df$x > 60 ] <- 1
df$mask[df$x > 640 ] <- 2
df_rug$mask<-c(rep(0,998),1,2)
require(ggplot2)
ggplot(df, aes(x = x))+
geom_histogram(aes(y=..density..),bins=20,color='black',fill='white')+
scale_x_continuous(breaks=c(seq(0,60,20),160,180,660))+
geom_rug(data = df_rug, aes(x = eigenv, y = Inf), color = 'red', sides = 'b')+
facet_grid(.~mask,scales='free', space='free')+
xlab('eigenvalues')+
theme(strip.background = element_blank(), strip.text.x = element_blank())
The code produces the following plot:
I had to create the 2 last panels, because the 2 last values of eigenv
are extreme values that I want to put in the histogram plot with a cut in the x-scale. However, the code puts 2 bars with a high density in the 2 last panels, but I don't want those bars, as I want density 0 for those panels. Is there a way to achieve that?