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

Bad displays #190

Closed
Lecrapouille opened this issue Oct 19, 2022 · 4 comments
Closed

Bad displays #190

Lecrapouille opened this issue Oct 19, 2022 · 4 comments

Comments

@Lecrapouille
Copy link

Hi ! Again to disturb you. Here is my matrix:

A = [3 7; 2 4]

Which corresponds to the expected network.
Expected

The following code

G = SimpleWeightedDiGraph(A)
gplot(G, nodelabel=1:nv(G), edgelabel=B)

gives me:
Obtained1

Issues are:

  • no edge labels on nodes cycling to themselves,
  • and in jupyter notebook the layout is truncated.

Based on #160 The following code

gplot(G, nodelabel=1:nv(G), edgelabel=B, linetype="curve")

gives me:
Obtained2

There are:

  • no edge labels on nodes cycling to themselves,
  • and in jupyter notebook the layout is truncated.
  • labels does not follow edges.
  • edgelabeldistx and edgelabeldisty do not fix.

I dunno if #186 will fix this simple graph.

@hdavid16
Copy link
Contributor

Thanks for pointing these out. #186 will allow you to make a plot like the first one with straight edges for the non-self loops, and curved edges for the self loops. The cut out can be fixed in the PR as well because you can add margins to ensure the curved edges are fully shown.

However, the edge labels on curved edges don't work as expected. Thanks for pointing this out. I'll see if we can get curved edge labels to work.

@hdavid16
Copy link
Contributor

@Lecrapouille,

I just stumbled upon GraphMakie.jl, which seems to be more actively developed and has better support for curved edges. Here is your example in GraphMakie

using Graphs, GraphMakie, CairoMakie

B = [3 7; 2 4]
g = SimpleDiGraph(B)
graphplot(g,
    layout = g -> [Point(-1,0), Point(1,0)],
    nlabels = string.("node ",1:nv(g)),
    elabels = string.([B[src(e),dst(e)] for e in edges(g)]), 
    elabels_rotation=0, 
    arrow_shift=0.99, 
    curve_distance = 0.1, 
    selfedge_size=1,
    selfedge_width=pi/9
)

This will produce the plot:
image

You can of course do much more customization on the appearance if you want. Now the edge labels will be in the right place.

@Lecrapouille
Copy link
Author

@hdavid16 Thanks you I'll give a try.

hdavid16 added a commit to hdavid16/GraphPlot.jl that referenced this issue Jan 24, 2023
@hdavid16
Copy link
Contributor

@Lecrapouille, I've added a commit to the PR #186 that will produce the following. This should fix the bug on the edge labels for curved edges.

B = [3 7; 2 4]
g = SimpleDiGraph(B)
gplot(g, [-1.,1.], [0.,0.],
    nodelabel=1:nv(g),
    edgelabel=B,
    linetype="curve",
    EDGELINEWIDTH=1,
    outangle=-pi/3,
    pad=5mm
)

image

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

No branches or pull requests

2 participants