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

Edges not curved #90

Open
BankNatchapol opened this issue May 29, 2024 · 3 comments
Open

Edges not curved #90

BankNatchapol opened this issue May 29, 2024 · 3 comments
Labels

Comments

@BankNatchapol
Copy link

From this example: https://netgraph.readthedocs.io/en/latest/sphinx_gallery_output/plot_06_labels.html#sphx-glr-sphinx-gallery-output-plot-06-labels-py
the graph should looks like this
image
but, it's this instead
image

@paulbrodersen
Copy link
Owner

Hi, thanks for raising the issue.

  1. Have you changed the value of k? This parameter determines the straightness of the edges.
g = Graph(triangle, edge_layout='curved', edge_layout_kwargs=dict(k=0.025))
  1. Does the issue persist on the dev branch?

You can install the dev branch via pip:

pip install https://github.com/paulbrodersen/netgraph/archive/dev.zip

@BankNatchapol
Copy link
Author

BankNatchapol commented May 30, 2024

@paulbrodersen Thank you for your answer.
i haved tried install with pip install https://github.com/paulbrodersen/netgraph/archive/dev.zip (nothing change)
and also tried removing edge_layout_kwargs=dict(k=0.025)
This is the result
image

which is still not completely correct, there should be 2 edges a->c and c->a

code:

import numpy as np
import matplotlib.pyplot as plt
import networkx as nx

from netgraph import Graph

fig, (ax1, ax2) = plt.subplots(1, 2)

triangle = [(0, 1), (0, 2), (1, 1), (1, 2), (2, 0)]

node_positions = {
    0 : np.array([0.2, 0.2]),
    1 : np.array([0.5, 0.8]),
    2 : np.array([0.8, 0.2]),
}

g = Graph(
    triangle,
    node_layout=node_positions, edge_layout='curved',
    node_labels={0 : 'a', 1 : 'b', 2 : 'c'},
    edge_labels=True, edge_label_fontdict=dict(fontweight='bold'),
    ax=ax1,
)

h = Graph(nx.complete_graph(7), edge_width=0.5, node_labels=True,
      node_label_fontdict=dict(size=14), node_label_offset=0.075, ax=ax2)

@paulbrodersen
Copy link
Owner

The edge layout key-word argument bundle_parallel_edges used to be False by default but is now True (no idea how that happened). You can restore the original behaviour by setting it to False explicitly:

g = Graph(
    triangle,
    node_layout=node_positions, edge_layout='curved', edge_layout_kwargs=dict(bundle_parallel_edges=False), 
    node_labels={0 : 'a', 1 : 'b', 2 : 'c'},
    edge_labels=True, edge_label_fontdict=dict(fontweight='bold'),
    ax=ax1,
)

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

No branches or pull requests

2 participants