I am making a plot using ggplot2 in R that has a discrete y-axis. I am using the ggridges package and the geom_density_ridges_gradient() plot type. These plots create a large space between the bottom of the figure and the labels of the x-axis. Is there a way to remove or shrink this added space?
Here is the code I'm using to make the plot.
library(tidyverse)
library(ggridges)
library(scales)
sample_q <- ggplot(data, aes(x=value/1000,y=factor(category),group=category)) +
geom_density_ridges_gradient(scale=.5) +
theme_ridges(center_axis_labels = TRUE,grid=TRUE) +
xlab("Values") +
ylab("Height") +
theme(text=element_text(size=10)) +
scale_x_continuous(expand = c(0,0), limits = c(-15,15), breaks=c(-15,-10,-5,0,5,10,15))
I've tried creating the plot with different values of 'scale'. Here are three plots with scale set equal to 2, 1, and .5.
You can see that the space between the bottom of the density plot and the x-axis labels is large and does not change with scales. I've tried without the theme_ridges line as well and the plot still has the same vertical space between the density plot and the x-axis labels. I'd like the x-axis labels to be just below the 'Group A' plot.