Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the position of nodes #18

Open
jesucastin opened this issue Dec 11, 2022 · 2 comments
Open

Fixing the position of nodes #18

jesucastin opened this issue Dec 11, 2022 · 2 comments
Labels
question Further information is requested

Comments

@jesucastin
Copy link

Hi, is there a way to specify custom XY coordinates in node properties? I want to arrange the nodes in various layouts.

@erdogant erdogant added the question Further information is requested label Jan 16, 2023
@erdogant
Copy link
Owner

erdogant commented Feb 25, 2023

I looked into this but choosing a specific layout is kind of hard because the nodes are freely moving. I did also experiment with a (un)freeze button that I created. The nodes could be frozen but correct dragging became challenging because of the network edges.

For the moment, I will not further investigate this for implementation until I see or hear a possible solution.

@fhg-isi
Copy link

fhg-isi commented Sep 20, 2024

Thank you for this great tool. I would also like to know how to used fixed node positions.

My use case is to visualize networkx graphs in an interactive way (hover titles for nodes and edges, possibility to zoom) and thought a python library based on d3.js could be very helpful. I do not need the force and drag features at all and would like to just display the networkx graph as is.


import networkx as nx
from d3graph import d3graph, vec2adjmat

# Create a NetworkX graph
G = nx.Graph()
G.add_nodes_from([((0, 0), {"capacity": 10}), ((100, 100), {"capacity": 5})])
G.add_edges_from([((0, 0), (100, 100), {"weight": 4.2})])

adj_matrix = nx.to_pandas_adjacency(G)
positions = {node: node for node in G.nodes}

# Initialize
d3 = d3graph()
# Proces adjmat
d3.graph(adj_matrix)

# Plot
d3.show()

# Make changes in node properties
d3.set_node_properties(
    color=adj_matrix.columns.values,
)
# Plot
d3.show(filepath="c://temp/")

Edit: Will use dash_leaflet for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants