1

I have a dataframe of 10 variables and I want boxplot of each of the variables arranged in two columns. Range of each variable is different, so I want different x axis of each one them below the box plot. Currently I tried this but unable to place axis at right position. Any help will be appreciated!!

library(ggplot2)
library(tidyr)

df <- data.frame(matrix(rnorm(2000), ncol = 10))
plot.data <- gather(df, variable, value)
# plot.data$out <- as.numeric(rep(input_data, each = nrow(x_train)))
p <- ggplot(plot.data, aes(x = 0,  y=value))
p <- p + geom_boxplot()
#p <- p + geom_point(aes(x = 0, y = test_data), color = "red") 
p <- p + facet_wrap(~variable, scales = "free_x", strip.position = 'top', ncol = 2)
p <- p + coord_flip()
p <- p + xlab("") + ylab("")
p <- p + theme(legend.position="none") + theme_bw() 
p <- p + theme(axis.text.x=element_blank(),
              axis.text.y=element_text(angle=90),
              axis.ticks.x=element_blank())
p
Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
Rajan
  • 453
  • 4
  • 22

0 Answers0