-
Notifications
You must be signed in to change notification settings - Fork 2.1k
How to customize x-axis labels for a stacked bar plot graph? #1617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think there are no problems with the package.
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_continuous(breaks = unique(df$b)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) |
Ah, this makes sense -- thanks for the hints! I have some more dataframes I want to plot similarly where b is not an integer but a factor. I figured out that I can plot it using
Since I am now dealing with factors, I assume I need to go back to If anyone else has any suggestions, I'd appreciate it! Best, |
It is not a good idea to And since you map on By the way, I think you should post your questions on website like Stackoverflow rather than on the issues of a package. It is not the right place to get help as it is dedicated to report issues and feature request. |
Thanks for the help, I appreciate it! |
Related to #1589 |
Closing as duplicate |
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:
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
The text was updated successfully, but these errors were encountered: