# Different behavior of zcolor in Scatter and Plot

**URL:** <https://discourse.julialang.org/t/different-behavior-of-zcolor-in-scatter-and-plot/22412>\
**Category:** Visualization\
**Created:** [March 27, 2019, 2:51pm UTC](https://discourse.julialang.org/t/different-behavior-of-zcolor-in-scatter-and-plot/22412 "2019-03-27T14:51:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noel\_Araujo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noel_araujo/32/4862_2.png) [@Noel\_Araujo](https://discourse.julialang.org/u/Noel_Araujo)\
**Post date:** [March 27, 2019, 2:51pm UTC](https://discourse.julialang.org/t/different-behavior-of-zcolor-in-scatter-and-plot/22412/1 "2019-03-27T14:51:59Z")

</div>

Hello,  
I noticed that I can change the color of markers easily in Scatter, but not in Plots.  
Here an example:

> using Plots
> 
> x = 1:0.1:10  
> y1 = x .+ 1  
> y2 = x .+ 2  
> y3 = x .+ 3
> 
> scatter(x, y1, color=:reds, zcolor=1)  
> scatter!(x, y2, color=:reds, zcolor=2)  
> scatter!(x, y3, color=:reds, zcolor=3)
> 
> plot(x, y1, color=:reds, zcolor=1)  
> plot!(x, y2, color=:reds, zcolor=2)  
> plot!(x, y3, color=:reds, zcolor=3)

Here, the results  
 ![scat](https://global.discourse-cdn.com/julialang/original/3X/a/a/aab3e737c59c21f369b9dc09b3df71817a6b75c3.png)  
 ![plot](https://global.discourse-cdn.com/julialang/original/3X/2/1/2153afb6e44b9f0fc598017a4689b416af1dfa1d.png)

Is this intentional ? 🤔🤔

---

<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:** [March 27, 2019, 3:25pm UTC](https://discourse.julialang.org/t/different-behavior-of-zcolor-in-scatter-and-plot/22412/2 "2019-03-27T15:25:08Z")

</div>

I don’t know if it’s directly intentional, but it’s by design. `zcolor` is an alias for `marker_z`. Use `line_z` to control the color of a line.

---

<div class="post-metadata">

**Author:** ![Noel\_Araujo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noel_araujo/32/4862_2.png) [@Noel\_Araujo](https://discourse.julialang.org/u/Noel_Araujo)\
**Post date:** [May 22, 2020, 5:09pm UTC](https://discourse.julialang.org/t/different-behavior-of-zcolor-in-scatter-and-plot/22412/3 "2020-05-22T17:09:12Z")

</div>

I noticed that my example does not work anymore. I got this long message:

```julia
Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: InexactError: trunc(Int64, NaN)
Stacktrace:
 [1] trunc at ./float.jl:703 [inlined]
 [2] round at ./floatfuncs.jl:124 [inlined]
 [3] _broadcast_getindex_evalf at ./broadcast.jl:631 [inlined]
 [4] _broadcast_getindex at ./broadcast.jl:614 [inlined]
 [5] getindex at ./broadcast.jl:564 [inlined]
 [6] copy at ./broadcast.jl:830 [inlined]
 [7] materialize at ./broadcast.jl:820 [inlined]
 [8] get(::ColorSchemes.ColorScheme{Array{RGBA{Float64},1},String,String}, ::Int64, ::Tuple{Float64,Float64}) at /home/noel/.julia/packages/ColorSchemes/3n8HS/src/ColorSchemes.jl:207
 [9] get(::PlotUtils.ContinuousColorGradient, ::Int64, ::Tuple{Float64,Float64}) at /home/noel/.julia/packages/PlotUtils/S1cG3/src/colorschemes.jl:18
 [10] get_markercolor(::Plots.Series, ::Float64, ::Float64, ::Int64) at /home/noel/.julia/packages/Plots/FYxdA/src/utils.jl:530
 [11] get_markercolor at /home/noel/.julia/packages/Plots/FYxdA/src/utils.jl:534 [inlined]
 [12] gr_draw_marker(::Plots.Series, ::Float64, ::Float64, ::Tuple{Float64,Float64}, ::Int64, ::Int64, ::Int64, ::Symbol) at /home/noel/.julia/packages/Plots/FYxdA/src/backends/gr.jl:329
 [13] gr_draw_markers(::Plots.Series, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Tuple{Float64,Float64}, ::Int64, ::Int64) at /home/noel/.julia/packages/Plots/FYxdA/src/backends/gr.jl:356
 [14] gr_draw_markers(::Plots.Series, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Tuple{Float64,Float64}) at /home/noel/.julia/packages/Plots/FYxdA/src/backends/gr.jl:347
 [15] gr_display(::Plots.Subplot{Plots.GRBackend}, ::Measures.Length{:mm,Float64}, ::Measures.Length{:mm,Float64}, ::Array{Float64,1}) at /home/noel/.julia/packages/Plots/FYxdA/src/backends/gr.jl:1653
 [16] gr_display(::Plots.Plot{Plots.GRBackend}, ::String) at /home/noel/.julia/packages/Plots/FYxdA/src/backends/gr.jl:673
 [17] gr_display at /home/noel/.julia/packages/Plots/FYxdA/src/backends/gr.jl:637 [inlined]
 [18] _display(::Plots.Plot{Plots.GRBackend}) at /home/noel/.julia/packages/Plots/FYxdA/src/backends/gr.jl:1973
 [19] display(::Plots.PlotsDisplay, ::Plots.Plot{Plots.GRBackend}) at /home/noel/.julia/packages/Plots/FYxdA/src/output.jl:150
 [20] display(::Any) at ./multimedia.jl:323
 [21] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [22] invokelatest at ./essentials.jl:711 [inlined]
 [23] print_response(::IO, ::Any, ::Bool, ::Bool, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:161
 [24] print_response(::REPL.AbstractREPL, ::Any, ::Bool, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:146
 [25] (::REPL.var"#do_respond#38"{Bool,REPL.var"#48#57"{REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:729
 [26] (::REPL.var"#53#62")(::Any, ::Any, ::Vararg{Any,N} where N) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:997
 [27] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [28] invokelatest at ./essentials.jl:711 [inlined]
 [29] (::REPL.LineEdit.var"#22#23"{REPL.var"#53#62",String})(::Any, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/LineEdit.jl:1364
 [30] prompt!(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/LineEdit.jl:2446
 [31] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/LineEdit.jl:2349
 [32] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:1055
 [33] run_repl(::REPL.AbstractREPL, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:206
 [34] (::Base.var"#764#766"{Bool,Bool,Bool,Bool})(::Module) at ./client.jl:383
 [35] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [36] invokelatest at ./essentials.jl:711 [inlined]
 [37] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:367
 [38] exec_options(::Base.JLOptions) at ./client.jl:305
 [39] _start() at ./client.jl:484

```

I’m running Julia v1.4.0 and Plots v1.3.2
