✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Is it possible to hide contour lines in Histogram2dContour() method for Python?

Is it possible to hide the contour lines from the Histogram2dContour plot in this example?

import plotly.graph_objs as go

import numpy as np

t = np.linspace(-1,1.2,2000)
x = (t3)+(0.3*np.random.randn(2000))
y = (t
6)+(0.3*np.random.randn(2000))

trace1 = go.Scatter(
x=x, y=y, mode=‘markers’, name=‘points’,
marker=dict(color=‘rgb(102,0,0)’, size=2, opacity=0.4)
)
trace2 = go.Histogram2dContour(
x=x, y=y, name=‘density’, ncontours=20,
colorscale=‘Hot’, reversescale=True, showscale=False
)
trace3 = go.Histogram(
x=x, name=‘x density’,
marker=dict(color=‘rgb(102,0,0)’),
yaxis=‘y2’
)
trace4 = go.Histogram(
y=y, name=‘y density’, marker=dict(color=‘rgb(102,0,0)’),
xaxis=‘x2’
)
data = [trace1, trace2, trace3, trace4]

layout = go.Layout(
showlegend=False,
autosize=False,
width=600,
height=550,
xaxis=dict(
domain=[0, 0.85],
showgrid=False,
zeroline=False
),
yaxis=dict(
domain=[0, 0.85],
showgrid=False,
zeroline=False
),
margin=dict(
t=50
),
hovermode=‘closest’,
bargap=0,
xaxis2=dict(
domain=[0.85, 1],
showgrid=False,
zeroline=False
),
yaxis2=dict(
domain=[0.85, 1],
showgrid=False,
zeroline=False
)
)

go.Figure(data=data, layout=layout)

Hi @sugar_donut,
To get a Histogram2dContour without contour lines remove from trace2 definition, ncontours=20, and insert
contours_showlines=False.

To get nicer 1d histograms, update layout as follows:

fig.update_layout(bargap=0.015)

Ah okay, no wonder because there is no contours_showlines argument in the doc! Thanks so much and also for the update layout tip!

@sugar_donut Have you searched the docs at https://plot.ly/python/reference/ ???

See here : https://plot.ly/python/reference/#histogram2dcontour-contours-showlines

I did but it was hard to navigate around because it’s a long list, that’s kinda unstructured, and none of the keywords I used pulled it up.