0

I created a histogram using the following code:

  ggplot(aes(as.numeric(Q30_1))) +
  geom_bar(fill = "lightblue", col = "black") +
  labs(x= "my variable", y= "Frequency") + 
  ggtitle("")

The variable scales from 1 to 10 and I want to show the frequency of each value. However, the x-axis scale only shows four values (2.5, 5, 7.5, 10).

This is the picture

How can I display each value (like 1,2,3,..., 10) on the x-axis?

Ritchie Sacramento
  • 29,890
  • 4
  • 48
  • 56
Santiago99
  • 143
  • 4

1 Answers1

0
df1 <- data.frame(Q30_1 = sample(1:10, 5000, replace = TRUE))
ggplot(df1, aes(as.numeric(Q30_1))) +
  geom_bar(fill = "lightblue", col = "black") +
  scale_x_continuous(breaks = 1:10, minor_breaks = NULL) +
  labs(x= "The level of support for the BLM", y= "Frequency")

enter image description here

Jon Spring
  • 55,165
  • 4
  • 35
  • 53