Skip to content

Could Plot.auto make the Simpsons cell heatmap? #1672

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

Closed
tophtucker opened this issue Jun 6, 2023 · 2 comments · Fixed by #1674
Closed

Could Plot.auto make the Simpsons cell heatmap? #1672

tophtucker opened this issue Jun 6, 2023 · 2 comments · Fixed by #1674
Labels
bug Something isn’t working

Comments

@tophtucker
Copy link
Contributor

Selecting a bar override on "season" vs "number_in_season" makes a bunch of zero-width, zero-height rects (and a working tooltip with some extraneous intervals): https://observablehq.com/d/58a592d7a3c97fc8

Plot.auto(simpsons, {x: "season", y: "number_in_season", color: "imdb_rating", mark: "bar"}).plot()

I wish it made this:

Plot.cell(simpsons, {x: "season", y: "number_in_season", fill: "imdb_rating"}).plot()

If there's no reducer / no binning by which to give the rects extent, could we infer that we could treat x and y as discrete and use cell instead? Though maybe that'd be brittle; it'd kinda depend on the numbers being evenly spaced.

@tophtucker tophtucker added the enhancement New feature or request label Jun 6, 2023
@Fil
Copy link
Contributor

Fil commented Jun 6, 2023

would it be mark: "cell", or "interval: 1" (which it should then do in both dimensions)

@mbostock mbostock added bug Something isn’t working and removed enhancement New feature or request labels Jun 6, 2023
@mbostock
Copy link
Member

mbostock commented Jun 6, 2023

I think this is a straight-up bug, not the intended behavior. I believe the code assumes that if we’re using the rect mark, that there’s a color reducer (and hence that x and y are binned). But that isn’t the case in the provided snippet.

Here are some options that I don’t immediately reject:

  1. Choose cell instead of rect as the mark implementation.
  2. Ignore the mark option and use dot instead.
  3. Throw an error explaining that a reducer is required. (I don’t like this one.)
  4. Add an implicit color reducer (median? mode? first?) to enable binning.
  5. Add an implicit interval option? (But how would we know what interval to use…)

To me (1) choosing cell instead of mark is likely the easiest fix and seems like the place to start. I think it’s this line here, but you have to check whether a colorReduce was specified.

: rect;

(I think we’d still chose cell if a sizeReduce was specified? But the inputs don’t make much sense since the bar mark doesn’t support a size encoding.)

I would not introduce a cell mark option as @Fil suggested. A big value-add of the auto mark is that the differences between the rect marks are ignorable and in the chart cell we wouldn’t want the user to choose between cell and bar (and rect).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants