# Scatter pallete application

**URL:** <https://discourse.julialang.org/t/scatter-pallete-application/40297>\
**Category:** New to Julia\
**Tags:** visualization\
**Created:** [May 27, 2020, 10:49pm UTC](https://discourse.julialang.org/t/scatter-pallete-application/40297 "2020-05-27T22:49:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Auhen\_Shauchuk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/auhen_shauchuk/32/15225_2.png) [@Auhen\_Shauchuk](https://discourse.julialang.org/u/Auhen_Shauchuk)\
**Post date:** [May 27, 2020, 10:49pm UTC](https://discourse.julialang.org/t/scatter-pallete-application/40297/1 "2020-05-27T22:49:44Z")

</div>

hello, i was trying to learn a bit of julia by doing some plotting although i have encountered some issues while using color palettes:

```julia
scatter(df.x, df.y, palette = :tab20b,
   xlabel = :x, ylabel = :y)

```

i have tried several backends and found that `color` keyword for palette application could be used although with no succes: all plotted points are of one color

what could i do with that?  
thanks

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 28, 2020, 7:14am UTC](https://discourse.julialang.org/t/scatter-pallete-application/40297/2 "2020-05-28T07:14:42Z")

</div>

There’s a slight misunderstanding here of how colours are applied in calls to `scatter`: every call to `scatter` creates a group of points which all have the same colour, by default the first colour of whatever colour palette you are specifying.

If you then call `scatter!` again (note the `!`, which indicates that the existing plot is modified), the next colour of your chosen colour palette is applied to the next group of points. Consider:

```julia
julia> using Plots

julia> scatter(ones(10), rand(10), palette = :tab20b)

julia> scatter!(1 .+ ones(10), rand(10), palette = :tab20b)

julia> scatter!(2 .+ ones(10), rand(10), palette = :tab20b)

julia> scatter!(3 .+ ones(10), rand(10), palette = :tab20b)

julia> scatter!(4 .+ ones(10), rand(10), palette = :tab20b)

julia> scatter!(5 .+ ones(10), rand(10), palette = :tab20b)

```

which creates:

![image](https://global.discourse-cdn.com/julialang/original/3X/7/f/7ff692de921780a5f967d11ceb55fb0e6d7a5c32.png)

If you want different colours within one series, you need to specify a vector of colours of the same length as the number of points you’re looking to plot:

```julia
julia> scatter(1:10, 1:10, palette = :tab20b, color = 1:10)

```

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

---

<div class="post-metadata">

**Author:** ![Auhen\_Shauchuk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/auhen_shauchuk/32/15225_2.png) [@Auhen\_Shauchuk](https://discourse.julialang.org/u/Auhen_Shauchuk)\
**Post date:** [May 28, 2020, 5:37pm UTC](https://discourse.julialang.org/t/scatter-pallete-application/40297/3 "2020-05-28T17:37:36Z")

</div>

hi, thank you for very detailed explanation!  
i went further and tried using another vector to color the points by value - is there way to supply palette to do it in Plots.jl ?

i have found a way to simply supply the vector in VegaLite and ggplot although would be nice to stick to one package for plotting
