-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Hi all,
I am trying to create a stacked area plot and label the x axis with the variables using scale_x_discrete
.
However, as soon as I add scale_x_discrete
to my code, the x axis gets wiped out:
My code looks as follows:
library(ggplot2)
set.seed(11)
df <- data.frame(a = rlnorm(30), b = 1:10, c = rep(LETTERS[1:3], each = 10))
ggplot(df, aes(x = b, y = a, fill = c)) +
geom_area(position = 'stack') +
scale_x_discrete(labels = levels(as.factor(df$b))) +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
Has this been a recent change? I have definitely been able to do this before and it didn't seem tricky, but I recently upgraded packages, so I'm not sure if that's what happened. Is there another function I can use to add x-axis labels to a stacked area plot?
Thanks for any advice you might have!
~Lina
Metadata
Metadata
Assignees
Labels
No labels