Skip to content

Color of contour lines on surface plot affected by axis range. #945

@peterjbrown519

Description

@peterjbrown519

Hi,

It seems that if the zaxis range is not set to 'auto' then the colors of the contour lines will default to the color of the surface itself. Here is a short code snippet that reproduces the bug.

import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np

# Bug where contour lines cannot be colored if they don't all appear on the plotted surface.

def f(x,y):
	return np.outer(x,y)

x = np.linspace(0.5,1,25)
y = np.linspace(0.5,1,25)
z = f(x,y)
surf = go.Surface(	x=x,
					y=y,
					z=z,
					contours = dict(z = dict(show=True,
							color='#111')
							)
				)
layout = go.Layout(
					scene = dict(
						zaxis = dict(
							rangemode = 'tozero'
				  		)
					)
				)
fig = go.Figure(data=[surf],layout=layout)
py.plot(fig, filename = 'bug')

With the rangemode option set to 'normal', we get the contour lines showing up as normal
Without custom range

But if we try to extend the z-axis to zero then the color of our contour lines changes to the colorscale of the plot. Note that in the example below the contour lines are still being plotted, their color has just changed.

With custom range

I wasn't sure if this should be posted in the python or the js repo but as I found the bug in python I'm posting it here.

Best,
Peter #

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions