我想从字典中获取唯一值。
输入:
{320: [167], 316: [0], 319: [167], 401: [167], 319: [168], 380: [167], 265: [166]}
Run Code Online (Sandbox Code Playgroud)
所需输出:
[167,0,168,166]
Run Code Online (Sandbox Code Playgroud)
我的代码:
unique_values = sorted(set(pff_dict.itervalues()))
Run Code Online (Sandbox Code Playgroud)
但是我得到这个错误: TypeError: unhashable type: 'list'
我想为数据中的每个点(3D)和标签提供标签(标签是字典中的键):
l = list(dictionary.keys())
#transform the array to a list
arrayx=arrayx.tolist()
arrayy=arrayy.tolist()
arrayz=arrayz.tolist()
#arrayx contains my x coordinates
ax.scatter(arrayx, arrayy, arrayz)
#give the labels to each point
for label in enumerate(l):
ax.annotate(label, ([arrayx[i] for i in range(27)],[arrayy[i]for i in range(27)],[arrayz[i] for i in range(27)]))
plt.title("Data")
plt.show()
Run Code Online (Sandbox Code Playgroud)
我的输入:
数组x:
[[0.7], [7.1], [7.5], [0.6], [0.5], [0.00016775708773695687]...]
Run Code Online (Sandbox Code Playgroud)
阵列:
[[0.1], [2], [3], [6], [5], [16775708773695687]...]
Run Code Online (Sandbox Code Playgroud)
数组z:
[1], [2], [3], [4], [5], [6]...]
Run Code Online (Sandbox Code Playgroud)
并为图中的每个点 3D 贴上标签