# In Gplots, draw PNG gplot applies incorrect edge label?

**URL:** <https://discourse.julialang.org/t/in-gplots-draw-png-gplot-applies-incorrect-edge-label/92033>\
**Category:** Visualization\
**Created:** [December 23, 2022, 6:03am UTC](https://discourse.julialang.org/t/in-gplots-draw-png-gplot-applies-incorrect-edge-label/92033 "2022-12-23T06:03:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Beckingham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colin_beckingham/32/4878_2.png) [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Post date:** [December 23, 2022, 6:03am UTC](https://discourse.julialang.org/t/in-gplots-draw-png-gplot-applies-incorrect-edge-label/92033/1 "2022-12-23T06:03:39Z")

</div>

I’m experimenting with drawing PNG images of graphs. All is well except that when I attempt to use edge weights as edge labels, all the correct weight values appear in the image, but they are on the wrong edges.

As I create the edges (iter) I create a random value for the weight, add the edge to the graph and then push the weight onto the end of a vector. This vector is then passed to the `gplot` function for the `edgelabel` to use.

`G.weights` shows the correct weights and consistently reports back the right numbers, so it is just the way that the entries are ordered in the vector supplied to the `gplot` that is the issue.

Any hints? I have tried fully implementing the weights and then digging into the weights matrix for values, but same result.

---

<div class="post-metadata">

**Author:** ![Colin\_Beckingham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colin_beckingham/32/4878_2.png) [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Post date:** [December 23, 2022, 6:59am UTC](https://discourse.julialang.org/t/in-gplots-draw-png-gplot-applies-incorrect-edge-label/92033/2 "2022-12-23T06:59:00Z")

</div>

Problem solved. I failed to sort my combinations after generation.

---

<div class="post-metadata">

**Author:** ![Colin\_Beckingham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colin_beckingham/32/4878_2.png) [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Post date:** [December 23, 2022, 11:13am UTC](https://discourse.julialang.org/t/in-gplots-draw-png-gplot-applies-incorrect-edge-label/92033/3 "2022-12-23T11:13:50Z")

</div>

I thought I had it, but repeated testing shows that I still have a problem somewhere. The first element seems to be consistently correct, but the remaining elements, while the adjacency matrix is good, do not transfer reliably to the correct edge on the plot. I’ll keep working it and will post an issue if I can’t find the reason for this odd result.

---

<div class="post-metadata">

**Author:** ![Colin\_Beckingham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colin_beckingham/32/4878_2.png) [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Post date:** [December 23, 2022, 1:35pm UTC](https://discourse.julialang.org/t/in-gplots-draw-png-gplot-applies-incorrect-edge-label/92033/4 "2022-12-23T13:35:04Z")

</div>

I have opened issue #192 in Graphplots at [Edgelabels attached to the wrong edges · Issue #192 · JuliaGraphs/GraphPlot.jl · GitHub](https://github.com/JuliaGraphs/GraphPlot.jl/issues/192) with sample code.

@hdperez contributed an alteration to my code in the above link which resolved my issue.
