# How to let a function return some numerical values and a graph simutaneously?

**URL:** https://discourse.julialang.org/t/how-to-let-a-function-return-some-numerical-values-and-a-graph-simutaneously/103101
**Category:** General Usage
**Tags:** function
**Created:** [August 23, 2023, 3:27am UTC](https://discourse.julialang.org/t/how-to-let-a-function-return-some-numerical-values-and-a-graph-simutaneously/103101 "2023-08-23T03:27:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)
#### Post date: [August 23, 2023, 3:27am UTC](https://discourse.julialang.org/t/how-to-let-a-function-return-some-numerical-values-and-a-graph-simutaneously/103101/1 "2023-08-23T03:27:54Z")

</div>

For example:

```julia
using UnicodePlots

function func(n)
    r = randn(n)
    s = sum(r)
    hist = histogram(r, nbins=10, closed=:left)
    r, s, hist
end

```

If I call this function in the REPL, it returns:

```julia
julia> func(10)
([1.5369990699727945, -0.7353913882824294, -0.8568141947726255, 1.145149668937184, 0.3340140471550356, 1.2364301576354533, 1.8932925331172032, 0.05768487009000112, -0.2116877502737839, 0.4638080551886433], 4.863485068767476, ┌ ┐
   [-1.0, -0.5) ┤████████████████████████▋ 2
   [-0.5, 0.0) ┤████████████▍ 1
   [ 0.0, 0.5) ┤█████████████████████████████████████ 3
   [ 0.5, 1.0) ┤ 0
   [ 1.0, 1.5) ┤████████████████████████▋ 2
   [ 1.5, 2.0) ┤████████████████████████▋ 2
                └ ┘
                                 Frequency )

```

As seen, the histogram is returned as an element of the tuple, which makes it display sickly. Is there any good solutions to this issue? Thanks.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [August 23, 2023, 4:48am UTC](https://discourse.julialang.org/t/how-to-let-a-function-return-some-numerical-values-and-a-graph-simutaneously/103101/2 "2023-08-23T04:48:49Z")

</div>

Doesn’t this do what you want already? If you want to display the histogram separately, do

```julia
julia> r, s, hist = func(10);
julia> hist

```

or

```julia
julia> func(10)[3] 

```
