I have a distance matrix:
dis_matrix = torch.tensor([[ 0.0000, 20.2615, 20.6478, 21.8596, 20.5779],
[20.2615, 0.0000, 21.4059, 22.5908, 21.6969],
[20.6478, 21.4059, 0.0000, 21.3755, 21.4672],
[21.8596, 22.5908, 21.3755, 0.0000, 24.2236],
[20.5779, 21.6969, 21.4672, 24.2236, 0.0000]])
Where the names are:
names = ['1', '2', '3', '4', '5']
How can I visualize it in 2D in matplotlib
? That is, plotting the name of each variable on a 2D plot that will be x
distance away from the other values (where x
is clearly the distances from the distance matrix).
There are many answers using networkx
(like here), or using MDS
(like here), but I just want to create a simple 2D plot using the distances.