# Weird behaviour on contour plot update

**URL:** <https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572>\
**Category:** Visualization\
**Tags:** plotting\
**Created:** [November 27, 2019, 12:06pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572 "2019-11-27T12:06:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre\_Mello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andre_mello/32/7333_2.png) [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Post date:** [November 27, 2019, 12:06pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/1 "2019-11-27T12:06:44Z")

</div>

It seems like if the differences in the contour levels are too small, updating the plot breaks its colors.

Here’s a MWE to make things clearer.

```julia
using Plots

x = -0.1:0.01:0.1
y = -0.1:0.01:0.1
z = [i^2+j^2 for i in x, j in y]

cont = contourf(x, y, z)
display(cont)
vline!(cont, [0.0])
hline!(cont, [0.0])
display(cont)

```

Am I doing anything wrong here?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 27, 2019, 2:17pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/2 "2019-11-27T14:17:23Z")

</div>

The MWE is too minimal. What is broken? The colors of the lines?

 ![minime](https://global.discourse-cdn.com/julialang/original/3X/d/b/db5c1bcbf2b9f4daab5f9f24279fab62cbd43ce0.jpeg)

---

<div class="post-metadata">

**Author:** ![Andre\_Mello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andre_mello/32/7333_2.png) [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Post date:** [November 28, 2019, 2:18am UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/3 "2019-11-28T02:18:06Z")

</div>

Oh that’s weird. The first graph, the one in the background, is just fine, like mine. The issue should be apparent in the second one, in the front. However yours is different from what I get. I’m attaching exactly what my MWE generates for me after running the `vline!` and `hline!`. I even have just tried updating the packages but I still get the following results.

![image](https://global.discourse-cdn.com/julialang/original/3X/1/3/13dc0b7e59bc298b7a6b23517a303a633ea45a38.png)

How can I troubleshoot this?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 28, 2019, 2:18pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/4 "2019-11-28T14:18:09Z")

</div>

Lets first check systems:

```julia
julia> versioninfo()
Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)
Environment:
  JULIA_PKGDIR = c:\Program Files\Julia-0.6.2\packages\
  JULIA_SHELL = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

(v1.2) pkg> status
    Status `C:\Users\oheil\.julia\environments\v1.2\Project.toml`
  [c52e3926] Atom v0.11.3
  [6e4b80f9] BenchmarkTools v0.4.3
  [aaaa29a8] Clustering v0.13.3
  [a93c6f00] DataFrames v0.19.4
  [b4f34e82] Distances v0.8.2
  [cd3eb016] HTTP v0.8.8
  [7073ff75] IJulia v1.20.2
  [682c06a0] JSON v0.21.0
  [b9914132] JSONTables v0.1.3
  [e5e0dc1b] Juno v0.7.2
  [ee78f7c6] Makie v0.9.5
  [d366530f] NormalizeQuantiles v1.0.0
  [91a5bcdd] Plots v0.27.0
  [295af30f] Revise v2.3.1
  [2913bbd2] StatsBase v0.32.0
  [f3b207a7] StatsPlots v0.13.0 [`C:\Users\oheil\.julia\dev\StatsPlots`]

(v1.2) pkg>

```

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [November 28, 2019, 2:28pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/5 "2019-11-28T14:28:20Z")

</div>

This looks like he did not pick up the correct color limits, try passing them explicitly:

```julia
cont = contourf(x, y, z, clims=(0.0,0.02))

```

---

<div class="post-metadata">

**Author:** ![Andre\_Mello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andre_mello/32/7333_2.png) [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Post date:** [November 29, 2019, 1:15pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/7 "2019-11-29T13:15:16Z")

</div>

Oh, that’s a good idea and it actually solves the issue.  
But still, `vline!` or `hline!` (or updating the plot in any other way) should not break the first plot. I guess I’ll use this for now, until I can find out exactly what’s going on with my system.

---

<div class="post-metadata">

**Author:** ![Andre\_Mello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andre_mello/32/7333_2.png) [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Post date:** [November 29, 2019, 1:29pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/8 "2019-11-29T13:29:10Z")

</div>

Hm I see you’re on Julia 1.2 and have the 0.27.0 version of Plots.  
I’m running on Julia 1.1 and I have Plots v0.28.1.

I’ll first see if upgrading to Julia 1.2 or 1.3 fixes the issue.

```julia
julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)

(v1.1) pkg> status                                                                                                                                    
    Status `~/.julia/environments/v1.1/Project.toml`                                                                                                  
  [c52e3926] Atom v0.11.3                                                                                                                             
  [6e4b80f9] BenchmarkTools v0.4.3                                                                                                                    
  [a134a8b2] BlackBoxOptim v0.5.0                                                                                                                     
  [ad839575] Blink v0.12.0                                                                                                                            
  [c5f51814] CUDAdrv v4.0.4                                                                                                                           
  [3a865a2d] CuArrays v1.4.7                                                                                                                          
  [eb300fae] DiffEqBiological v4.0.2                                                                                                                  
  [aae7a2af] DiffEqFlux v0.7.0                                                                                                                        
  [1130ab10] DiffEqParamEstim v1.9.0                                                                                                                  
  [0c46a032] DifferentialEquations v6.8.0                                                                                                             
  [b4f34e82] Distances v0.8.2                                                                                                                         
  [31c24e10] Distributions v0.21.9                                                                                                         
  [f6369f11] ForwardDiff v0.10.7                                                                                                                      
  [28b8d3ca] GR v0.44.0                                                                                                                               
  [c91e804a] Gadfly v1.0.1                                                                                                                            
  [7073ff75] IJulia v1.20.2                                                                                                                           
  [c601a237] Interact v0.10.3                                                                                                                         
  [b6b21f68] Ipopt v0.6.1                                                                                                                             
  [4076af6c] JuMP v0.20.1                                                                                                                             
  [e5e0dc1b] Juno v0.7.2      
  [44063525] NODAL v0.4.0
  [09606e27] ODEInterfaceDiffEq v3.5.0
  [47be7bcc] ORCA v0.3.0
  [5fb14364] OhMyREPL v0.5.3
  [429524aa] Optim v0.19.4
  [1dea7af3] OrdinaryDiffEq v5.23.0
  [65888b18] ParameterizedFunctions v4.2.1
  [f0f68f2c] PlotlyJS v0.13.0
  [91a5bcdd] Plots v0.28.1
  [438e738f] PyCall v1.91.2
  [d330b81b] PyPlot v2.8.2

```

---

<div class="post-metadata">

**Author:** ![Andre\_Mello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andre_mello/32/7333_2.png) [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Post date:** [November 29, 2019, 1:59pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/9 "2019-11-29T13:59:56Z")

</div>

This seems to be a bug in the Plots v0.28.1.

What I did was:  
I first upgraded Julia to 1.3 and the issue persisted. I tried fixing the Plots version with `pin Plots@0.27.0` but that didn’t work either.  
So I removed Plots altogether and explicitly installed Plots v0.27.0 and now everything works as expected.

Should this be turned to a Github Issue?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 29, 2019, 2:24pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/10 "2019-11-29T14:24:28Z")

</div>

I can try to reiterate with Julia 1.3 + Plots 0.28.1  
And if I reproduce it would be great if you open up a issue.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 29, 2019, 2:29pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/11 "2019-11-29T14:29:30Z")

</div>

Confirmed, with command

```julia
julia> vline!(cont, [0.0])

```

the plot breaks.

```julia
julia> versioninfo()
Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: AMD Ryzen 5 3600 6-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, znver1)

(v1.2) pkg> status
    Status `C:\Users\Oli\.julia\environments\v1.2\Project.toml`
  [c52e3926] Atom v0.11.3
  [6e4b80f9] BenchmarkTools v0.4.3
  [b99e7846] BinaryProvider v0.5.8
  [aaaa29a8] Clustering v0.13.3
  [b4f34e82] Distances v0.8.2
  [e5e0dc1b] Juno v0.7.2
  [d366530f] NormalizeQuantiles v1.0.0
  [91a5bcdd] Plots v0.28.1
  [295af30f] Revise v2.3.1
  [90137ffa] StaticArrays v0.12.1
  [2913bbd2] StatsBase v0.32.0
  [f3b207a7] StatsPlots v0.13.0

```

---

<div class="post-metadata">

**Author:** ![Andre\_Mello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andre_mello/32/7333_2.png) [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Post date:** [November 29, 2019, 2:45pm UTC](https://discourse.julialang.org/t/weird-behaviour-on-contour-plot-update/31572/12 "2019-11-29T14:45:05Z")

</div>

Thanks for confirming! I have just opened the issue here:  
[https://github.com/JuliaPlots/Plots.jl/issues/2288](https://github.com/JuliaPlots/Plots.jl/issues/2288)
