lets-plot icon indicating copy to clipboard operation
lets-plot copied to clipboard

geom_bar: aes 'fill' and trans 'log10' break y scale

Open ASmirnov-HORIS opened this issue 2 years ago • 3 comments

Example:

n = 1000
np.random.seed(42)
data = {
    "x": np.random.choice(["a", "b", "c"], p=[.49, .49, .02], size=n),
    "g": np.random.choice(["X", "Y"], size=n),
}
ggplot(data, aes(x="x", fill="g")) + geom_bar() + scale_y_continuous(trans='log10')

Output:

Screenshot_2023_02_24

Label values on y axis are much greater than expected. There is no such trouble if fill="g" or trans='log10' will be removed.

ASmirnov-HORIS avatar Feb 24 '23 16:02 ASmirnov-HORIS

@ASmirnov-HORIS is this still the observed behavior in 4.3.0 ?

alshan avatar Mar 29 '24 20:03 alshan

Yes. Now only powers of 10 are left on the y-axis, but the values are still larger than they should be.

ASmirnov-HORIS avatar Apr 01 '24 11:04 ASmirnov-HORIS

The thing is, in case of 'stack' position adj. we sum transformed values. And if the transform is 'log' transform we have: log(256) + log(236) ~= 4.78 (and "unlog": 10^4.78 ~= 60255)

instead of expected: log(256 + 236) ~= 2.69

alshan avatar Apr 10 '24 21:04 alshan