Skip to content

Marginal histograms ignore z/histfunc in density_heatmap/density_contour #5704

Closed

Description

@lucasjamar

Related to #3521 (closed as stale in 2024, reopening as a fresh issue per maintainer request).

For 2D histograms and contour plots, marginal histograms (marginal_x/marginal_y="histogram") always show raw bin counts, regardless of the z value and histfunc passed to density_heatmap/density_contour. The main plot correctly aggregates z via histfunc, but the marginal subplots do not.

Example:

import plotly.express as px
df = px.data.tips()

fig = px.density_heatmap(
    df, x="size", y="tip", z="total_bill", histfunc="sum",
    marginal_x="histogram", marginal_y="histogram",
)
fig.show()

Expected: the marginal histograms show the sum of total_bill per bin, matching the main heatmap.
Actual: the marginal histograms show raw row counts per bin.

I have a fix ready and will open a PR referencing this issue.

Activity

  1. added
    bug
    P3
    on Aug 17, 2026
  2. robertclaus commented on Aug 17, 2026

    @robertclaus

    @lucasjamar thanks for reporting and opening the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3bugsize: 1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions