我正在尝试绘制 30x2322 权重矩阵的热图,并在末尾添加偏差。这是代码:
def plotNetworkParams(fn, input_labels):
np = loadFile(fn)
input_mx = numpy.vstack([np[1], np[2]]) #stack bias to weight mx
input_mx = numpy.transpose(input_mx)
colorscale = [[0, '#000000'], [0.4, '#0000FF'], [0.5, '#FFFFFF'], [0.6, '#FFFF00'], [1, '#FF0000']]
print "input mx shape: "+str(input_mx.shape) # prints (30, 2323)
print "number of labels: "+str(len(input_labels)) # prints 2323
data = [
go.Heatmap(
zauto=False,
zmin=-0.5,
zmax=0.5,
colorscale = colorscale,
z=input_mx,
y=map(lambda n: "Activation of unit "+str(n), range(30)),
x=input_labels
)
]
py.plot(data, filename="input_to_recurrent")
该图 x 轴上的标签少于列。我使用标签和数据之间的偏移量追溯到丢失的各个标签。 例如,索引 275 和 277 处的标签在图表上彼此相邻,标签 276 缺失,标签 277 获取标签 276 的数据等等。
什么会导致plotly丢失这样的标签?
最佳答案
事实证明我的输入具有相同的标签。 Plotly 有一个“功能”,可以默默地删除相同的标签。
关于python - Plotly 似乎丢失了热图的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40742473/