Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using fill: "count" with the group or bin transform, implicitly set color: {zero: true} #2089

Open
mbostock opened this issue Jun 14, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

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:

untitled - 2024-06-14T122823 384

Plot.plot({
  color: {scheme: "YlGnBu", legend: true},
  marks: [
    Plot.rect(penguins, Plot.groupX({fill: "count"}, {x: "species"}))
  ]
})

With zero:

untitled - 2024-06-14T122833 962

Plot.plot({
  color: {zero: true, scheme: "YlGnBu", legend: true},
  marks: [
    Plot.rect(penguins, Plot.groupX({fill: "count"}, {x: "species"}))
  ]
})
@mbostock mbostock added the enhancement New feature or request label Jun 14, 2024
@Fil
Copy link
Contributor

Fil commented Jun 15, 2024

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()

@mbostock
Copy link
Member Author

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.

@Fil
Copy link
Contributor

Fil commented Jun 16, 2024

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]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants