I have the following plot, is there any way in ggplot to display just the numbers 1 to 10 instead of all of them?
Numbers from 10 and after are not so important, but I need to display the ones before.
Thank you
$\begingroup$
$\endgroup$
2
-
1$\begingroup$ the easy fix ( if numbers after 10 are not need) is to filter data to have N from 1 to 10 and plot this data $\endgroup$– Yaroslaw HomenkoCommented Feb 7, 2019 at 10:36
-
$\begingroup$ have you tryed adding the scale_x_continuous(limits=c(1, 10)) ? Is part of ggplot2 so make sure you run install.packages "ggplot2"and right after run library(ggplot2) Let me know if that helps. Laura $\endgroup$– Laura Sofia BayonaCommented Aug 26, 2021 at 12:29
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
I used this kind of wor around, but if you have another solution, please enlighten me :)
df %>%
ggplot() +
geom_bar(mapping = aes(x = N%>% as.factor())) +
xlab(label = 'N') +
theme(axis.text.x = element_text(angle = 45, size = 8))