user1595929
user1595929

Reputation: 1372

ggplot2 boxplot with space respect between boxes

I display a boxplot chart as following:

enter image description here

But what I would like is to have the x axis as real x axis, meaning that the space between values should be respected. Adding to this scale I would like a log scale on the x axis. How can I do this using geom_boxplot?

thanks, Jerome

Upvotes: 0

Views: 273

Answers (1)

lukeA
lukeA

Reputation: 54277

what I would like is to have the x axis as real x axis, meaning that the space between values should be respected. Adding to this scale I would like a log scale on the x axis. How can I do this using geom_boxplot?

You could do

set.seed(1)
df <- data.frame(x=rep(c(1,10,50,100), each=10), y=runif(40))
library(ggplot2)
ggplot(df, aes(x, y, group=x)) + 
  geom_boxplot() + 
  scale_x_log10() + 
  theme_minimal()

enter image description here

Upvotes: 2

Related Questions