I am trying to create a stacked bargraph with a logged y-axis. I don't want to transform my entire dataset, just the y-axis so that I can spread out some of my smaller bars. I am trying to use coord_trans. Whenever I try a log transformation, I get an error message for every single individual bar saying "Transformation introduced infinite values in y-axis". If I use the same code with a sqrt transformation, everything works fine. So it must be something with the log transformation. Have you encountered this problem before? I have included the code for the plot I am using below.
library(ggplot2)
dput(Bef_bio)
structure(list(Treat = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), .Label = c("Con",
"N", "P"), class = "factor"), Functional_Group = structure(c(5L,
5L, 5L, 4L, 4L, 4L, 1L, 1L, 1L, 7L, 7L, 7L, 6L, 6L, 6L, 3L, 3L,
3L, 2L, 2L, 2L), .Label = c("One", "Two", "Three", "Four", "Five",
"Six", "Seven"), class = "factor"), BV_mm3L = c(0.284504136,
0.414444186666667, 3.75290346275, 0, 0, 0, 0.118510033666667,
0.0218816683333333, 17.942747818875, 0, 0, 0, 0.668984741333333,
0.436479357333333, 1.310577009625, 3.16931740733333, 1.5116585285,
2.07553807775, 0.188271552, 0.165778386333333, 10.2304435985)), row.names =
c(NA,
-21L), class = "data.frame")
plot<-ggplot()+geom_bar(aes(y=BV_mm3L, x=Treat, fill=Functional_Group), colour="black", data=Bef_bio, stat="identity"))
plot
plot<-plot+coord_trans(y="log10")
plot
I apologize that I do not know how to make a reproducible dataset here.