Python plotly - create_dendrogram 中的错误
Python plotly - Error in create_dendrogram
我是 运行 plotly.py jupyter notebook 中的 4.8.2 版。
我运行以下代码,复制自documentation page:
import plotly.figure_factory as ff
import numpy as np
np.random.seed(1)
X = np.random.rand(10,10)
fig = ff.create_dendrogram(X)
fig.update_layout(width=800, height=500)
fig.show()
并收到以下错误消息:
KeyError Traceback (most recent call last)
in
4
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 )
101
~/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)
144
145 (dd_traces, xvals, yvals, ordered_labels, leaves) = self.get_dendrogram_traces(
–> 146 X, colorscale, distfun, linkagefun, hovertext, color_threshold
147 )
148
~/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’
示例代码有问题吗?或者可能与我的环境有关?
谢谢!
我们将很快在 Plotly.py 中修复此问题,但暂时不要升级到 scipy
1.5.0 并继续使用 1.4.1。
我是 运行 plotly.py jupyter notebook 中的 4.8.2 版。
我运行以下代码,复制自documentation page:
import plotly.figure_factory as ff
import numpy as np
np.random.seed(1)
X = np.random.rand(10,10)
fig = ff.create_dendrogram(X)
fig.update_layout(width=800, height=500)
fig.show()
并收到以下错误消息:
KeyError Traceback (most recent call last)
in
4
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 )
101
~/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)
144
145 (dd_traces, xvals, yvals, ordered_labels, leaves) = self.get_dendrogram_traces(
–> 146 X, colorscale, distfun, linkagefun, hovertext, color_threshold
147 )
148
~/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’
示例代码有问题吗?或者可能与我的环境有关?
谢谢!
我们将很快在 Plotly.py 中修复此问题,但暂时不要升级到 scipy
1.5.0 并继续使用 1.4.1。