✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Error in create_dendrogram example


I am running plotly.py version 4.8.2 in a jupyter notebook.
I ran the following code, copied from the documentation page:

import plotly.figure_factory as ff
import numpy as np

X = np.random.rand(10,10)
fig = ff.create_dendrogram(X)
fig.update_layout(width=800, height=500)

and getting the following error message:

KeyError Traceback (most recent call last)
5 X = np.random.rand(10,10)
----> 6 fig = ff.create_dendrogram(X)
7 fig.update_layout(width=800, height=500)
8 fig.show()

~/miniconda3/envs/jupyterlab/lib/python3.7/site-packages/plotly/figure_factory/_dendrogram.py in create_dendrogram(X, orientation, labels, colorscale, distfun, linkagefun, hovertext, color_threshold)
97 linkagefun=linkagefun,
98 hovertext=hovertext,
—> 99 color_threshold=color_threshold,
100 )

~/miniconda3/envs/jupyterlab/lib/python3.7/site-packages/plotly/figure_factory/_dendrogram.py in init(self, X, orientation, labels, colorscale, width, height, xaxis, yaxis, distfun, linkagefun, hovertext, color_threshold)
145 (dd_traces, xvals, yvals, ordered_labels, leaves) = self.get_dendrogram_traces(
–> 146 X, colorscale, distfun, linkagefun, hovertext, color_threshold
147 )

~/miniconda3/envs/jupyterlab/lib/python3.7/site-packages/plotly/figure_factory/_dendrogram.py in get_dendrogram_traces(self, X, colorscale, distfun, linkagefun, hovertext, color_threshold)
335 y=np.multiply(self.sign[self.yaxis], ys),
336 mode=“lines”,
–> 337 marker=dict(color=colors[color_key]),
338 text=hovertext_label,
339 hoverinfo=“text”,

KeyError: ‘C1’

Is there something wrong with the example code? Or maybe something about my environment?

Thanks for creating an issue in Github! I’ll follow up there :slight_smile: https://github.com/plotly/plotly.py/issues/2618