Skip to content

Aligning histograms and density plots #289

@teunbrand

Description

@teunbrand

We currently have an example in the density documentation where this works out reasonably well by accident.
However if we pick flipper_len instead of bill_len we see misalignment happening.

VISUALISE flipper_len AS x FROM ggsql:penguins
DRAW histogram 
  REMAPPING density AS y
  SETTING opacity => 0.5
DRAW density
  SETTING opacity => 0.5

Currently the histogram density is computed as:

{count} * 1.0 / SUM({count})

To get good alignment with the density layer, we'd need to account for the binwidth as well.
I'm proposing the current histogram density variable becomes fraction or something, and have a new density computation that divides by the binwidth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    plot buildingIn between the reader and writer, execution of plot logic
    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions