Skip to content

only default to bar for x or y is zeroed#1273

Merged
mbostock merged 2 commits into
mainfrom
mbostock/fix-auto-bar
Feb 15, 2023
Merged

only default to bar for x or y is zeroed#1273
mbostock merged 2 commits into
mainfrom
mbostock/fix-auto-bar

Conversation

@mbostock

Copy link
Copy Markdown
Member

Fixes #1272.

@mbostock mbostock requested review from Fil and tophtucker February 15, 2023 17:02
@mbostock mbostock changed the title only default to bar for zeroed reducers only default to bar for x or y is zeroed Feb 15, 2023

@Fil Fil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

BTW I'm not sure #1238 has documented the reducer's zero option? I can't see it.

@mbostock

Copy link
Copy Markdown
Member Author

I think this is better, but I think we could still refine this logic. Like, it makes sense to me that this is a line:

Screenshot 2023-02-15 at 9 16 00 AM

Plot.auto(weather, {x: "date", y: {value: "temp_max", reduce: "mean"}}).plot()

But I’m not convinced that we should switch to a bar when you tell it that zero is meaningful:

Screenshot 2023-02-15 at 9 16 48 AM

Plot.auto(weather, {x: "date", y: {value: "temp_max", reduce: "mean", zero: true}}).plot()

I think a line + zero rule would be equally appropriate (and less arbitrarily different):

Screenshot 2023-02-15 at 9 17 42 AM

Plot.auto(weather, {x: "date", y: {value: "temp_max", reduce: "mean", zero: true}, mark: "line"}).plot()

Or perhaps even an area:

Screenshot 2023-02-15 at 9 18 53 AM

Plot.auto(weather, {x: "date", y: {value: "temp_max", reduce: "mean"}, mark: "area"}).plot()

On the other hand, I think it would be surprising if histograms rendered as lines or areas by default, but I can’t articulate why.

Screenshot 2023-02-15 at 9 20 21 AM

Plot.auto(weather, {x: "temp_max", mark: "line"}).plot()

@mbostock mbostock merged commit 6eab4f2 into main Feb 15, 2023
@mbostock mbostock deleted the mbostock/fix-auto-bar branch February 15, 2023 17:32
@mbostock mbostock mentioned this pull request Feb 15, 2023
13 tasks
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* only default to bar for zeroed reducers

* default bar if x or y is zeroed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The auto mark should not default to bars when the reduce is not sum or count (e.g., don’t stack means)

2 participants