Skip to content

Commit

Permalink
Make grid a bit bigger to avoid weird vis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesyan-git committed Aug 23, 2023
1 parent 7a0c809 commit 93d353a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions examples/add-graph-networkx.py → examples/add_graph_networkx.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@
import napari

hex_grid = nx.hexagonal_lattice_graph(5, 5, with_positions=True)
# make grid a bit bigger
nx.set_node_attributes(
hex_grid,
{
k: (10 * v[0], 10 * v[1])
for k, v in nx.get_node_attributes(hex_grid, 'pos').items()
},
'pos',
)
# below conversion not needed after napari/napari-graph#11 is released
hex_grid_ints = nx.convert_node_labels_to_integers(hex_grid)

viewer = napari.Viewer()
layer = viewer.add_graph(hex_grid_ints, size=1)
layer.edges_visible = np.random.random(len(hex_grid_ints.edges)) > 0.5
layer = viewer.add_graph(
hex_grid_ints, size=1, face_color='pink', edges_visible=False
)
# layer.edges_visible = np.random.random(len(hex_grid_ints.edges)) > 0.5

if __name__ == "__main__":
napari.run()

0 comments on commit 93d353a

Please sign in to comment.