# Warning messages when creating colormaps with PyPlot

**URL:** <https://discourse.julialang.org/t/warning-messages-when-creating-colormaps-with-pyplot/6343>\
**Category:** New to Julia\
**Tags:** visualization\
**Created:** [October 9, 2017, 5:10am UTC](https://discourse.julialang.org/t/warning-messages-when-creating-colormaps-with-pyplot/6343 "2017-10-09T05:10:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![metjmart](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@metjmart](https://discourse.julialang.org/u/metjmart)\
**Post date:** [October 9, 2017, 5:10am UTC](https://discourse.julialang.org/t/warning-messages-when-creating-colormaps-with-pyplot/6343/1 "2017-10-09T05:10:40Z")

</div>

I have a handful of colormaps that I’ve created in Julia through PyPlot. The function that I use to create these colormaps triggers a warning message in v0.6.0 that I’m not sure how to fix.

For example, if I try to create a colormap as follows:

```julia
using PyPlot

blue_r_cmap =Pyplot.ColorMap("blue_r",
[(0.0,1.0,1.0),(0.1,1.0,1.0),(1.0,0.0,0.0)],
[(0.0,1.0,1.0),(0.1,1.0,1.0),(1.0,0.0,0.0)],
[(0.0,1.0,1.0),(0.1,1.0,1.0),(1.0,0.7,0.7)],33,1.0)

```

I get a warning message stating:

```julia
WARNING: Array{T}(::Type{T}, m::Int) is deprecated, use Array{T}(m) instead.

Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] Array(::Type{Tuple{Float64,Float64,Float64}}, ::Int64) at ./deprecated.jl:57
 [3] PyPlot.ColorMap(::String, ::Array{Tuple{Float64,Float64,Float64},1}, ::Array{Tuple{Float64,Float64,Float64},1}, ::Array{Tuple{Float64,Float64,Float64},1}, ::Int64, ::Float64) at /home/metjon/.julia/v0.6/PyPlot/src/colormaps.jl:61
 [4] include_string(::String, ::String) at ./loading.jl:515
 [5] include_string(::Module, ::String, ::String) at /home/metjon/.julia/v0.6/Compat/src/Compat.jl:464
 [6] execute_request(::ZMQ.Socket, ::IJulia.Msg) at /home/metjon/.julia/v0.6/IJulia/src/execute_request.jl:154
 [7] eventloop(::ZMQ.Socket) at /home/metjon/.julia/v0.6/IJulia/src/eventloop.jl:8
 [8] (::IJulia.##14#17)() at ./task.jl:335
while loading In[3], in expression starting on line 1

```

I tried working around this issue by changing the format of the input arrays as suggested by the warning message but I couldn’t find a way to get it to work. I’m probably overlooking something rather simple, but I’d appreciate any suggestions on how to get rid of this warning message. Since I’m loading in a handful of these colormaps, the warning message gets pretty lengthy.

Thanks!

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [October 9, 2017, 7:21am UTC](https://discourse.julialang.org/t/warning-messages-when-creating-colormaps-with-pyplot/6343/2 "2017-10-09T07:21:13Z")

</div>

My guess is that this warning is cast from inside PyPlot - it’s the kind of warning you get when a syntax is not updated from julia 0.5 to 0.6. You can most likely ignore it.

---

<div class="post-metadata">

**Author:** ![metjmart](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@metjmart](https://discourse.julialang.org/u/metjmart)\
**Post date:** [October 11, 2017, 9:58pm UTC](https://discourse.julialang.org/t/warning-messages-when-creating-colormaps-with-pyplot/6343/3 "2017-10-11T21:58:16Z")

</div>

You’re likely correct that the warning message is cast from inside PyPlot. It is indeed innocuous, however I was hoping there’s a way I can restructure the arrays such that the warning message is not triggered. It’s rather lengthy and I’d favor finding the correct syntactical solution (provided one exists) that gets rid of the warning message. Any thoughts on how to go about this?

Thanks for the feedback!

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [October 12, 2017, 2:02am UTC](https://discourse.julialang.org/t/warning-messages-when-creating-colormaps-with-pyplot/6343/4 "2017-10-12T02:02:58Z")

</div>

A workaround is to not let `PyPlot` use its obsolete form for the default alpha channels:

```julia
blue_r_cmap =PyPlot.ColorMap("blue_r",
[(0.0,1.0,1.0),(0.1,1.0,1.0),(1.0,0.0,0.0)],
[(0.0,1.0,1.0),(0.1,1.0,1.0),(1.0,0.0,0.0)],
[(0.0,1.0,1.0),(0.1,1.0,1.0),(1.0,0.7,0.7)],
Array{Tuple{Float64,Float64,Float64}}(0),
33,1.0)

```

The correct (syntactical?) solution is to turn this into a PR for the PyPlot package.
