问题
This plot is great. It has everything I need, and the y=0
value is in a sensible place despite the logarithmic scale. All is great!
library(ggplot2)
df <- data.frame(x=1:3, y=c(1, 0, 2))
print(ggplot(df, aes(x=x, y=y)) + geom_point() + scale_y_log10())
How can I suppress this warning, and only this warning?
Transformation introduced infinite values in continuous y-axis
回答1:
you can handle it by out of bounds argument. Please find the code below.
library(ggplot2)
df <- data.frame(x=1:3, y=c(1, 0, 2))
print(ggplot(df, aes(x=x, y=y)) + geom_point() + scale_y_log10(oob = scales::squish_infinite)
来源:https://stackoverflow.com/questions/63522128/how-can-i-suppress-transformation-introduced-infinite-values-warnings-in-r