Hi,
I am trying to create a plot from 2 sets of data similar to the one produced here.
I want to plot the performance of a PDP
plot but also want to put the amount of people in a rug plot below the PDP model similar to the link above. I can't seem to make it work. Can anyone see where I am going wrong
library(tidyverse, quietly = TRUE)
# Give you your main data
x = sample(1:7, replace = TRUE, size = 1000)
y = sample(seq(1:1000), replace = TRUE, size = 1000)/1000
main_df <- tibble(x,y) %>%
group_by(x) %>%
summarise(n = mean(y))
# Number of People to be used for the rug plot
score <- seq(1, 7, length.out = 17)
n <- sample(1:100, 17)
rug_data <- tibble(score, n)
# Attempt to plot it (line and point work find separately but when combined with rug plot gives a poor plot)
ggplot(main_df, aes(x=x, y=n)) +
geom_line() +
geom_point() +
geom_rug(data=rug_data, aes(x=score, alpha = n), col="steelblue", size=1.5, sides="b")
Thanks