# Weird plot behavior within function

**URL:** <https://discourse.julialang.org/t/weird-plot-behavior-within-function/35932>\
**Category:** New to Julia\
**Created:** [March 13, 2020, 4:01pm UTC](https://discourse.julialang.org/t/weird-plot-behavior-within-function/35932 "2020-03-13T16:01:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wizebt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wizebt/32/12256_2.png) [@wizebt](https://discourse.julialang.org/u/wizebt)\
**Post date:** [March 13, 2020, 4:01pm UTC](https://discourse.julialang.org/t/weird-plot-behavior-within-function/35932/1 "2020-03-13T16:01:17Z")

</div>

Hi,  
Trying to display plots within a function, no plot window was showing. Digging to the root here is the issue: tp() is displaying plot and not tp1()? Cannot get the rational on why a function returning any value including nothing is blocking ‘GKS Qterm’ to show? From a plot usage perspective It doesn’t make sense to me …  
Thanks

```julia
 using Plots

function tp()
	a = rand(Float32,9)
	b = rand(Float32,9)
	plot(a)
	plot!(b)
end

function tp1()
	a = rand(Float32,9)
	b = rand(Float32,9)
	plot(a)
	plot!(b)
	
	return a
end

```

---

<div class="post-metadata">

**Author:** ![dmolina](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmolina/32/5246_2.png) [@dmolina](https://discourse.julialang.org/u/dmolina)\
**Post date:** [March 13, 2020, 4:24pm UTC](https://discourse.julialang.org/t/weird-plot-behavior-within-function/35932/2 "2020-03-13T16:24:46Z")

</div>

You have to call display. In the first one, the repl is visualizing the result because it is a plot. In the second one, it is not the case. However, using display you guarantee to show it.

---

<div class="post-metadata">

**Author:** ![wizebt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wizebt/32/12256_2.png) [@wizebt](https://discourse.julialang.org/u/wizebt)\
**Post date:** [March 13, 2020, 7:05pm UTC](https://discourse.julialang.org/t/weird-plot-behavior-within-function/35932/3 "2020-03-13T19:05:00Z")

</div>

Works like a charm 🙂 many thanks
