Skip to content

geom_boxplot() + scale_y_log10() bug #1020

Closed
@ra81

Description

@ra81

This bug cost me a full day of working.

Some sample of working code

abc <- adply(matrix(rnorm(100, mean = 20, sd = 5), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
abc$X1  <- NULL
abc$X1  <- c(1:5)
abc[6, ]  <- c(10, 18, 20, 25, 1000, 6)

# working code
b <- ggplot(abc, aes(group=X1, x = X1, ymin = `0%`, lower = `25%`, middle = `50%`, upper = `75%`, ymax = `100%`))
 b + geom_boxplot(stat = "identity", aes(fill=X1)) + coord_trans(y="log10")

This all ok. Picture is ok.
image

# broken code
b <- ggplot(abc, aes(group=X1, x = X1, ymin = `0%`, lower = `25%`, middle = `50%`, upper = `75%`, ymax = `100%`))
d <- b + geom_boxplot(stat = "identity") + scale_y_log10()

ggplot makes ranges of y axe as c(0.8490745, 3.1024250).
max value from abc is 1000 = 10^3.
y range upper bound = 10^3 + small margin. So it is log scale.
BUT when data is plotted ggplot uses absolute values of abc data not log values.
So we have wrong picture
image

Problem like this was discussed here
#274
http://stackoverflow.com/questions/9502003/ggplot-scale-y-log10-issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions