Problem: When using scale_y_continuous() the Y axis label is removed.
Example:
dat <- data.frame(variable = c("A","B","C"),
value = c(0.5,0.25,0.25)
)
ggplot(dat, aes(variable, value)) +
geom_bar() +
scale_y_continuous("", formatter="percent") +
labs(y="Proportion",x="Type")
Is there a way to force the label to show when using scale_y_continuous()?
Yes. It seems to me that the label disappears because you told it to be a blank string, and the later call to
labs(y=...)doesn’t override this. Both of the following alternative formulations work:Option 1 is to not use
scale_y_continuous(formatter=...), i.e. don’t provide any label text.Option 2 is to specify the label text in the the call to scale directly, i.e.
scale_y_continuous("Proportion", ...):