# GraphPlot: calling gplot() inside function does often not work (in Atom)

**URL:** https://discourse.julialang.org/t/graphplot-calling-gplot-inside-function-does-often-not-work-in-atom/35086
**Category:** Visualization
**Created:** [February 24, 2020, 7:44pm UTC](https://discourse.julialang.org/t/graphplot-calling-gplot-inside-function-does-often-not-work-in-atom/35086 "2020-02-24T19:44:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)
#### Post date: [February 24, 2020, 7:44pm UTC](https://discourse.julialang.org/t/graphplot-calling-gplot-inside-function-does-often-not-work-in-atom/35086/1 "2020-02-24T19:44:54Z")

</div>

Dear community,

I observe a strange behavior when plotting graphs with GraphPlot. In most cases it refuses to plot the input graph if I call gplot() via a function. However, sometimes (in rare cases) it works. Calling gplot() from the global scope works fine. Here is a minimal example:

```julia
using LightGraphs
using GraphPlot

function myPlotFunction( g::SimpleDiGraph )
    gplot( g )
    return nothing
end

g = SimpleDiGraph( 5 )
add_edge!(g, 1, 2)
add_edge!(g, 3, 4)

# THIS DOES NOT PLOT 
myPlotFunction( g )

# THIS PLOTS AS EXPECTED
gplot( g )

```

Do you have any suggestions how to fix that? Does anyone else observe this? I am on Ubuntu 18.04, Julia 1.1.0.

Thanks in advance.

---

<div class="post-metadata">

### Author: ![oliver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliver/32/19264_2.png) [@oliver](https://discourse.julialang.org/u/oliver)
#### Post date: [March 2, 2020, 10:32pm UTC](https://discourse.julialang.org/t/graphplot-calling-gplot-inside-function-does-often-not-work-in-atom/35086/2 "2020-03-02T22:32:34Z")

</div>

I removed `return nothing` from the function and it seems to generate correctly.

---

<div class="post-metadata">

### Author: ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)
#### Post date: [March 3, 2020, 8:01am UTC](https://discourse.julialang.org/t/graphplot-calling-gplot-inside-function-does-often-not-work-in-atom/35086/3 "2020-03-03T08:01:55Z")

</div>

Great thanks,… that is probably the reason why it “often” did not work for me. I terminate void functions with “return nothing” in most cases.
