plot
plot copied to clipboard
When using `fill: "count"` with the group or bin transform, implicitly set `color: {zero: true}`
When the group or bin transform is used to generate a fill channel with the count reducer, we want the color scale domain to include zero by default. Otherwise the color scale starts at the lowest value, which can make these low values hard to read, and overemphasize the difference in valid.
Without zero:
Plot.plot({
color: {scheme: "YlGnBu", legend: true},
marks: [
Plot.rect(penguins, Plot.groupX({fill: "count"}, {x: "species"}))
]
})
With zero:
Plot.plot({
color: {zero: true, scheme: "YlGnBu", legend: true},
marks: [
Plot.rect(penguins, Plot.groupX({fill: "count"}, {x: "species"}))
]
})
Is this not the case with any scale, not just color? In other words should we not default y to zero: true for
Plot.dot(penguins, Plot.groupX({ y: "count" }, { x: "species" })).plot()
Good question! Often we don’t think about it because the bar or rect mark requires zero, and the r scale by default includes zero. What do you think? And in any case you should be able to opt-out of this by setting zero: false on the scale.
I think it would make sense to generalize — I've noticed that often, when using a line mark with a bin transform; the y domain then starts at 1 (or whatever the lower count is), and you have to "fix" this by adding a ruleY([0]).