Weird behaviour on contour plot update

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.

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?

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

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

How can I troubleshoot this?

Lets first check systems:

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>
1 Like

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

cont = contourf(x, y, z, clims=(0.0,0.02))
1 Like

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.

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> 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
1 Like

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?

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.

1 Like

Confirmed, with command

julia> vline!(cont, [0.0])

the plot breaks.

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

Thanks for confirming! I have just opened the issue here:

1 Like