# How to Plot with gr() at the same time with showing computation result at the terminal Julia REPL?

**URL:** https://discourse.julialang.org/t/how-to-plot-with-gr-at-the-same-time-with-showing-computation-result-at-the-terminal-julia-repl/90545
**Category:** General Usage
**Tags:** question, plotting
**Created:** [November 20, 2022, 4:14pm UTC](https://discourse.julialang.org/t/how-to-plot-with-gr-at-the-same-time-with-showing-computation-result-at-the-terminal-julia-repl/90545 "2022-11-20T16:14:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)
#### Post date: [November 20, 2022, 4:14pm UTC](https://discourse.julialang.org/t/how-to-plot-with-gr-at-the-same-time-with-showing-computation-result-at-the-terminal-julia-repl/90545/1 "2022-11-20T16:14:04Z")

</div>

Hi all,

this is a double problems but want to be combined as one.

I want to show a plot of function (just simple plot, no need for the Newton’s method iteration shown, but if it is possible you can tell me).

Plus the result of the root obtained / the solution of the Newton method. I am using `MTH229`

(+) I want to ask whether using `f'(x)` is better than SymPy? How to check it? `btime`?  
(-) I have to type at terminal manually `plot(f)` to show the graph. I want it to be automatically shown at the same time as the result from the Newton’s method iterations.

this is my code:

```julia
# Julia for Newton's method 

using MTH229, Plots, LaTeXStrings, SymPy
gr()
@vars x

f(x) = sin(x) - x/4
fp(x) = f'(x)

plot(f, -10, 10, ylims=(-5,10),
    label=L"f(x)", framestyle=:zerolines,
     legend=:outerright)

newton(f, fp, 2pi, verbose=true)

#type at terminal: plot(f)

```

 ![Capture d’écran_2022-11-20_23-13-39](https://global.discourse-cdn.com/julialang/original/3X/c/8/c867b4decacd826e744e3aecbefb6f61e0407450.png)

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [November 20, 2022, 4:29pm UTC](https://discourse.julialang.org/t/how-to-plot-with-gr-at-the-same-time-with-showing-computation-result-at-the-terminal-julia-repl/90545/2 "2022-11-20T16:29:21Z")

</div>

Just do `display(plot(...))` or swap the calls around so that `plot` is called last and to `println(newton(...))` to print the result to the REPL?

---

<div class="post-metadata">

### Author: ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)
#### Post date: [November 20, 2022, 4:42pm UTC](https://discourse.julialang.org/t/how-to-plot-with-gr-at-the-same-time-with-showing-computation-result-at-the-terminal-julia-repl/90545/3 "2022-11-20T16:42:26Z")

</div>

I know why use `display(plot(...))` does not work neither put plot on the last.

I am still using Julia 1.7.3 and hesitate to upgrade due to afraid of no backward compatibility for old codes…

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [November 20, 2022, 6:50pm UTC](https://discourse.julialang.org/t/how-to-plot-with-gr-at-the-same-time-with-showing-computation-result-at-the-terminal-julia-repl/90545/4 "2022-11-20T18:50:16Z")

</div>

Sorry I’m not sure I understand - you’ve marked my post as the solution but are you saying it’s not actually working?

I would not worry about upgrading from 1.7 to 1.8, it’s an upgrade from one minor release to another which by Semver rules is non-breaking (also you can install multiple Julia versions in parallel so checking whether this works probably takes all of ten minutes and won’t affect your 1.7 installation).

---

<div class="post-metadata">

### Author: ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)
#### Post date: [November 21, 2022, 7:27am UTC](https://discourse.julialang.org/t/how-to-plot-with-gr-at-the-same-time-with-showing-computation-result-at-the-terminal-julia-repl/90545/5 "2022-11-21T07:27:38Z")

</div>

Yes it is not working to show the plot at the same time as the computation for Newton’s method, but since I haven’t use newer Julia version I mark it as solution, who knows the problem is in my Julia version.

I will try to make Julia installation parallel then. Thanks!
