You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support marginal_x/marginal_y="heatmap" in density_heatmap/density_contour #5706
For density_heatmap/density_contour, it would be great to specify a heatmap as the marginal plot type as well: a single-row (for marginal_x) or single-column (for marginal_y) heatmap in the margins, colored by the same aggregate (z/histfunc) as the main plot, instead of a bar chart.
Thanks for the issue and PR @lucasjamar! I think this is a reasonable feature request.
Are you able to share some examples of the types of charts you're trying to create, or data you're trying to visualize? That would be helpful for discussion if you're able to share.
I propose removing density_contour from the scope of this work, and supporting marginal heatmaps only for density_heatmap.
Two reasons:
px.density_heatmap() doesn't use color fills by default, so there's no extra synergy achieved by pairing marginal heatmaps with density_contour plots. At that point, you might as well allow marginal heatmaps for all plot types (which is another possibility!)
Possibly more important: Even if you do manually add fills to the density_contour plot, colorbars for histogram2dcontour traces (which is what density_contour uses under the hood) aren't compatible with heatmap colorbars. Heatmap colorbars are continuous, while histogram2dcontour colorbars are discrete and place labels at the contour boundaries. This results in weird visual artifacts and a misleading colorbar when using the PR implementation (see screenshot below), and I'm not sure if there's a way to reconcile the two (although maybe it's possible).
Thanks for the issue and PR @lucasjamar! I think this is a reasonable feature request.
Are you able to share some examples of the types of charts you're trying to create, or data you're trying to visualize? That would be helpful for discussion if you're able to share.
I propose removing density_contour from the scope of this work, and supporting marginal heatmaps only for density_heatmap.
Two reasons:
px.density_heatmap() doesn't use color fills by default, so there's no extra synergy achieved by pairing marginal heatmaps with density_contour plots. At that point, you might as well allow marginal heatmaps for all plot types (which is another possibility!)
Possibly more important: Even if you do manually add fills to the density_contour plot, colorbars for histogram2dcontour traces (which is what density_contour uses under the hood) aren't compatible with heatmap colorbars. Heatmap colorbars are continuous, while histogram2dcontour colorbars are discrete and place labels at the contour boundaries. This results in weird visual artifacts and a misleading colorbar when using the PR implementation (see screenshot below), and I'm not sure if there's a way to reconcile the two (although maybe it's possible).
For reference, here's what the `histogram2dcontour` colorbar looks like normally:
The implementation for `density_heatmap`, on the other hand, looks pretty reasonable and I'd be happy to have it as a feature.
Let us know your thoughts!
i see the issue, i therefore removed support and now its only density heatmap that is supported.
Activity
robertclaus commentedon Aug 17, 2026
@lucasjamar thank you for submitting this and opening a PR! If you don't mind adding an image too that would be great!
lucasjamar commentedon Aug 18, 2026
addressed in 789b082
robertclaus commentedon Aug 18, 2026
@lucasjamar I meant an image in the PR description to show the feature. That commit doesn't seem to have an image if you meant something else?
emilykl commentedon Aug 20, 2026
Thanks for the issue and PR @lucasjamar! I think this is a reasonable feature request.
Are you able to share some examples of the types of charts you're trying to create, or data you're trying to visualize? That would be helpful for discussion if you're able to share.
I propose removing
density_contourfrom the scope of this work, and supporting marginal heatmaps only fordensity_heatmap.Two reasons:
px.density_heatmap()doesn't use color fills by default, so there's no extra synergy achieved by pairing marginal heatmaps withdensity_contourplots. At that point, you might as well allow marginal heatmaps for all plot types (which is another possibility!)density_contourplot, colorbars forhistogram2dcontourtraces (which is whatdensity_contouruses under the hood) aren't compatible with heatmap colorbars. Heatmap colorbars are continuous, whilehistogram2dcontourcolorbars are discrete and place labels at the contour boundaries. This results in weird visual artifacts and a misleading colorbar when using the PR implementation (see screenshot below), and I'm not sure if there's a way to reconcile the two (although maybe it's possible).Code:
Screenshot:
For reference, here's what the
histogram2dcontourcolorbar looks like normally:The implementation for
density_heatmap, on the other hand, looks pretty reasonable and I'd be happy to have it as a feature.Let us know your thoughts!
lucasjamar commentedon Aug 23, 2026
i see the issue, i therefore removed support and now its only density heatmap that is supported.
lucasjamar commentedon Aug 23, 2026
done