Skip to content

Color of Contour lines in Surfaces with colormap are not correctly set #5006

Open
@jparisu

Description

@jparisu

I think there is an issue in the way the lines plot by a contours in a Surface object when selecting the color.
I think the color is not being correctly selected by each of the lines. They are supposed to follow the colorscale, but they just follows half of it.

Here there is a minimum example of code to simulate the error:

import numpy as np
import plotly.graph_objects as go

x = np.linspace(0, 1, 100)
y = np.linspace(0, 1, 100)
x_grid, y_grid = np.meshgrid(x, y)

z = x_grid + y_grid

params = {
    'colorscale': 'rainbow',
    'surfacecolor': z,
    'showscale': True,
    'colorbar': {
        'title': 'z',
    },
    'contours_z': {
        'show': True,
        'usecolormap': True,
        "project_z": True,
    }
}

trace = go.Surface(
    x=x,
    y=y,
    z=z,
    **params)

fig = go.Figure(data=[trace])
fig.write_image("test.png")
fig.show()

In the example, the expected behavior will be for the contour lines to be the same color as the surface, but they are not.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions