getting ALL Y axis ticks to display labels

hello,
data.frame(
stringsAsFactors = FALSE,
Rescan1 = c("No", "Yes"),
n = c(140L, 19L),
prop = c(0.880503144654088, 0.119496855345912)
)

here is my code:
'''
ggplot(prostate_cleaned_scaled, aes(x=Rescan1, fill=Rescan1, y = prop)) + geom_col()+ scale_fill_manual(values = c("Green", "Red")) + geom_text( aes(label=n, vjust=1)) + scale_x_discrete(limits = c("Yes", "No")) + theme(legend.position = "none") + labs(y="Proportion", x= "Rescan")
'''

The graph here only labels every alternate tick (i.e. 0.00, 0.25, 0.5). Is there any way in which

  1. I can get all the label ticks displayed?
  2. The proportion i.e. (0.88 displayed alongside the actual numbers on the top of the barcharts)

Thanks,

hello,
data.frame(
stringsAsFactors = FALSE,
Rescan1 = c("No", "Yes"),
n = c(140L, 19L),
prop = c(0.880503144654088, 0.119496855345912)
)

here is my code:

ggplot(prostate_cleaned_scaled, aes(x=Rescan1, fill=Rescan1, y = prop)) + geom_col()+ scale_fill_manual(values = c("Green", "Red")) + geom_text( aes(label=n, vjust=1)) + scale_x_discrete(limits = c("Yes", "No")) + theme(legend.position = "none") + labs(y="Proportion", x= "Rescan")

The graph here only labels every alternate tick (i.e. 0.00, 0.25, 0.5). Is there any way in which

  1. I can get all the label ticks displayed?
  2. The proportion i.e. (0.88 displayed alongside the actual numbers on the top of the barcharts)

Thanks,

this is one way

(mybreaks <- round(0:10/10,2))
ggplot(prostate_cleaned_scaled, 
       aes(x=Rescan1, fill=Rescan1, y = prop)) +
  geom_col()+ 
  scale_fill_manual(values = c("Green", "Red")) +
  geom_text( aes(label=paste0(n," : ",round(prop,2)), vjust=1)) +
  scale_x_discrete(limits = c("Yes", "No")) +
  theme(legend.position = "none") + 
  labs(y="Proportion", x= "Rescan") +
  scale_y_continuous(breaks = mybreaks,
                     labels = mybreaks,
                     minor_breaks = NULL)

Thanks again..much appreciated

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.