expansion
Generate expansion vector for scales and then convert them with ggplotly
p <- ggplot(mtcars) + geom_bar(aes(x = factor(cyl))) + scale_y_continuous(expand = expansion(mult = c(0, .1)))
plotly::ggplotly(p)
p <- ggplot(subset(diamonds, carat > 2), aes(cut, clarity)) + geom_jitter() + scale_x_discrete(expand = expansion(add = 2))
plotly::ggplotly(p)
p <- ggplot(subset(diamonds, carat > 2), aes(cut, price)) + geom_jitter() + scale_x_discrete(expand = expansion(add = .6)) + scale_y_continuous(expand = expansion(mult = .05))
plotly::ggplotly(p)