Closed
Description
When I'm log-scaling the y-axis of CDF-plots (stat_ecdf
), the y-values are drawn between 1 and 10 instead of 0 and 1. The y-values of the data extracted from the plot-object (ggplot_build(...)$data[[1]]$y
) are ranging from 0 to 1 instead of -1 to 0. When I'm log-scaling the x-axis of CDF-Plots or the x- or y-axis of other plots (e.g. geom_line
), everything is drawn as expected.
library(ggplot2)
df <- data.frame(var=1:10/10)
plot_ecdf_ident <- ggplot(df, aes(x=var)) + stat_ecdf()
plot_ecdf_log10_y <- plot_ecdf_ident + scale_y_log10()
plot_ecdf_log10_x <- plot_ecdf_ident + scale_x_log10()
plot_line_ident <- ggplot(df, aes(x=var, y=var)) + geom_line()
plot_line_log10_y <- plot_line_ident + scale_y_log10()
plot_line_log10_x <- plot_line_ident + scale_x_log10()
patchwork::wrap_plots(
plot_ecdf_ident, plot_ecdf_log10_y, plot_ecdf_log10_x,
plot_line_ident, plot_line_log10_y, plot_line_log10_x,
nrow=2
)
range(ggplot_build(plot_ecdf_log10_y)$data[[1]]$y)
#> [1] 0 1
range(ggplot_build(plot_line_log10_y)$data[[1]]$y)
#> [1] -1 0
packageVersion("ggplot2")
#> [1] '3.4.0'
packageVersion("scales")
#> [1] '1.2.1'
Created on 2022-12-20 with reprex v2.0.2