Mathematica Asked on July 9, 2021
An arbitrary example:
Create a random image
Image[RandomReal[{0, 1}, {10, 10}], ImageSize -> Medium]
Define some points and a graph to align
c = PixelValuePositions[%, White, .1]
RandomGraph[Table[Length[c], 2]]
Out[1]: {{2, 9}, {1, 8}, {1, 7}, {2, 7}, {9, 6}, {2, 2}}
How can I align the nodes of a graph to coordinates on an image?
Ideally this would be a graph from a correlation matrix
RandomReal[{-1, 1}, Table[Length[c], 2]] // MatrixForm
SeedRandom[1]
img = Image[RandomReal[{0, 1}, {10, 10}], ImageSize -> Medium];
c = PixelValuePositions[img, White, .1];
rg = RandomGraph[Table[Length[c], 2], ImageSize -> Medium];
rg2 = SetProperty[rg,
{VertexCoordinates -> c - 1/2, EdgeStyle -> Directive[Red, Thick]}];
Row[{rg, Show[img, rg2]}]
Correct answer by kglr on July 9, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP