0

I've made a barplot using ggplot with the code:

ggplot(data = PTC, mapping = aes(x = Genotype, fill = Smoker)) +
  geom_bar(position = position_dodge()) +
  ggtitle("Barplot of Genotype and Smoking Status") +
  scale_fill_discrete(name = "Smoking Status",
                      breaks = c("N", "S"),
                      labels = c("Non-smoker", "Smoker")) +
  scale_y_discrete("Number of Individuals") +
  geom_text(aes(label =..count..), stat = "count", position = position_dodge(width = 0.9), vjust = 1.25)

This gives me the following result:

enter image description here

Why the plot doesn't have scales on the y-axis?

user438383
  • 5,716
  • 8
  • 28
  • 43
Aris
  • 1
  • 3
    Your `y` axis values look continuous but you are using `scale_y_discrete()`. Are you just trying to set the axis label? Maybe use `labs(y="Number of Individuals") + ` instead of altering the scale. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Nov 09 '21 at 19:36
  • 3
    Try with with `scale_y_continuous` instead of `scale_y_discrete`. – stefan Nov 09 '21 at 19:38
  • Yes, it works! Thank you so much. – Aris Nov 09 '21 at 19:50

0 Answers0