MUCollective / pgog

Supplemental to A Probabilistic Grammar of Graphics
14 stars 1 forks source link

Visual aesthetics (alpha, color, fill) for continuous variable (numeric type) mapping #90

Open xiaoyingpu opened 4 years ago

xiaoyingpu commented 4 years ago

For geom_bloc -> area plots. (density plots seem fine). Leftover from issue PR #88

For example, the following code should work, but the second one throws Error: Discrete value supplied to continuous scale

ggplot(mtcars) + geom_bloc(aes(width = c(P(cyl)), fill = cyl)) # this doesn't color the blocks
ggplot(mtcars) + geom_bloc(aes(width = c(P(cyl)), fill = (cyl))) # this throws an error

This already works

ggplot(mtcars) + geom_bloc(aes(width = c(P(cyl)), fill = factor(cyl)))
xiaoyingpu commented 4 years ago

@citywallum have you gotten a sense of where the error is coming from?

citywallum commented 4 years ago

The reason that fill = cyl doesn't generate output or report error is that my algorithm looks for patter "factor(...)", if the variable is not quoted, the variable name would not be passed as "extra_var". So the main job now is to fix "Error: Discrete value supplied to continuous scale". I believe if this error got fixed, fill = cyl would work( by just modifying the parsing algorithm a bit, it would be easy)