# Bug? Plots + pyplot()

**URL:** https://discourse.julialang.org/t/bug-plots-pyplot/70940
**Category:** Visualization
**Tags:** jupyter, pyplot, plots, gr
**Created:** [November 4, 2021, 8:20am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940 "2021-11-04T08:20:54Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [November 4, 2021, 8:20am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940/1 "2021-11-04T08:20:54Z")

</div>

I’m on Windows 11 (64bit), latest update as of now. I use Julia v1.6.3, latest update as of today with all packages.

When I do simple plots using the `pyplot()` backend, my **Jupyter notebook crashes** with the following error message:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/5/3539cb1d973dc5e7ce187d5f0dc1a5bb6bf56658.png)

If I switch to `gr()` backend, the code runs without problems.

The same happens if I run another notebook.

The problem appears to have started a few days ago when I updated the Julia packages, where amongst others `pyplot()` had to be installed via `Conda.add()`, etc.

The reason why I still prefer to use `pyplot()` over `gr()` is that:

- `gr()` still has weak spots wrt. rendering text with LaTeX symbols.
- `gr()` sometimes gives “ugly” results, e.g., the following when plotting the result of a Turing model fit:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/d/ed312bd5f50289090fa21fd4087e8961bcc22b1d.png)  
[GR incorrectly doesn’t show the ylabel in the left column, and the label in the right column (“Density)” is written into the area of the left column.]

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [November 4, 2021, 9:39am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940/2 "2021-11-04T09:39:56Z")

</div>

> [@BLI](#):
>
> `gr()` sometimes gives “ugly” results

It would be nice to have a MWE example to try to understand when and why this sometimes happens. Thank you.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [November 4, 2021, 10:11am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940/3 "2021-11-04T10:11:54Z")

</div>

OK – for the Kernel restarting problem:

```julia
using Plots
pyplot()
#
x = range(0,2pi,length=50)
plot(x,sin)

```

leads to

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/e/be08d5b260f3d97f2aa8eb373098fd42359c3440.png)

while

```julia
using Plots
#pyplot()
#
x = range(0,2pi,length=50)
plot(x,sin)

```

uses `gr()` and works.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [November 4, 2021, 10:15am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940/4 "2021-11-04T10:15:08Z")

</div>

> [@rafael.guerra](#):
>
> It would be nice to have a MWE example to try to understand when and why this sometimes happens. Thank you.

This happens with `gr()` every time I run a Turing problem and do:

```julia
par_NUTS = sample(model,NUTS(100,0.75),Npos)
plot(par_NUTS)

```

leads to

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/b/dbe954871f4792e98c2516c9aefd43650fdf9287.png)

I can try to can make a complete, yet simple MWE. Possibly by stealing an example from the Turing documentation.

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [November 4, 2021, 10:48am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940/5 "2021-11-04T10:48:35Z")

</div>

Not familiar with `Turing.jl` but it seems that some Plots recipe is missing/broken.  
Have you tried `using StatsPlots` to see if an appropriate recipe is triggered?

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [November 4, 2021, 11:36am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940/6 "2021-11-04T11:36:51Z")

</div>

Yes, I have included `using StatsPlots` – with the same result. Note: `pyplot` handed this fine – that is, before it started to kill the kernel…

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [November 4, 2021, 11:38am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940/7 "2021-11-04T11:38:35Z")

</div>

Ok, maybe you should open an issue then.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [November 4, 2021, 11:47am UTC](https://discourse.julialang.org/t/bug-plots-pyplot/70940/8 "2021-11-04T11:47:21Z")

</div>

I’ll try to do that. The bigger problem for me, though, is that `pyplot()` makes the notebook session crash.
