plotly / plotly/plotly.py

go.Histogram2dContour does not normalize when using shared coloraxis and coloring='fill'

Open
#4,465 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3 sev-2
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

Setup:
plotly==5.18.0

Bug:
When adding two go.Histogram2dContour to a subplot, the colorscale is not normalized, when using a shared coloraxis and setting coloring='fill'.
It works when setting coloring='heatmap'.

Dataframes used:

df_a = pd.DataFrame({
    'a':[0,0,1,1],
    'b':[0,1,0,1],
    'c':[0,1,2,3],
    
})

df_b = pd.DataFrame({
    'a':[0,0,1,1],
    'b':[0,1,0,1],
    'c':[10,20,30,40],
    
})

Example coloring='fill':
histogram2dContour_fill

Example coloring='heatmap':
histogram2dContour_heatmap

Code:

fig = make_subplots(rows=1,cols=2)

fig.add_trace(
            go.Histogram2dContour(
                x=df_a['a'].to_list(),
                y=df_a['b'].to_list(),
                z=df_a['c'].to_list(),
                # contours=dict(coloring="heatmap"),
                contours=dict(coloring="fill"),
                coloraxis="coloraxis",
                showscale=True,
                showlegend=False,
                histfunc='max',
            ),
            row=1,
            col=1
        )

fig.add_trace(
            go.Histogram2dContour(
                x=df_b['a'].to_list(),
                y=df_b['b'].to_list(),
                z=df_b['c'].to_list(),
                # contours=dict(coloring="heatmap"),
                contours=dict(coloring="fill"),
                coloraxis="coloraxis",
                showscale=True,
                showlegend=False,
                histfunc='max',
            ),
            row=1,
            col=2
        )

fig.show()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided plotly==5.18.0 reproduction with two go.Histogram2dContour traces and compare coloring='fill' with coloring='heatmap'. Trace how shared coloraxis normalization is applied in each mode; done means both fill contours use the shared colorscale consistently across the two subplots.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.