1
$\begingroup$

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

My plot

$\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$ Commented 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$ Commented Aug 26, 2021 at 12:29

1 Answer 1

0
$\begingroup$

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))

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.