Skip to content

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

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

Open
PhilippHa3 opened this issue Dec 17, 2023 · 1 comment
Labels
bug something broken P3 backlog sev-2 serious problem

Comments

@PhilippHa3
Copy link

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()
@Coding-with-Adam Coding-with-Adam added bug something broken sev-2 serious problem P2 considered for next cycle labels Dec 18, 2023
@Coding-with-Adam
Copy link
Contributor

This might be a bug. Thanks for reporting, @PhilippHa3

Here's the full code that reproduces the bug:

import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots


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],

})

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()

@Coding-with-Adam Coding-with-Adam removed the P2 considered for next cycle label Jan 18, 2024
@gvwilson gvwilson self-assigned this Jul 11, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the P3 backlog label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog sev-2 serious problem
Projects
None yet
Development

No branches or pull requests

3 participants