# Plots.jl: using push! to add a new scatter plot series with a specified color

**URL:** https://discourse.julialang.org/t/plots-jl-using-push-to-add-a-new-scatter-plot-series-with-a-specified-color/15206
**Category:** New to Julia
**Created:** [September 20, 2018, 12:09am UTC](https://discourse.julialang.org/t/plots-jl-using-push-to-add-a-new-scatter-plot-series-with-a-specified-color/15206 "2018-09-20T00:09:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Phillip\_Sutton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phillip_sutton/32/7603_2.png) [@Phillip\_Sutton](https://discourse.julialang.org/u/Phillip_Sutton)
#### Post date: [September 20, 2018, 12:09am UTC](https://discourse.julialang.org/t/plots-jl-using-push-to-add-a-new-scatter-plot-series-with-a-specified-color/15206/1 "2018-09-20T00:09:00Z")

</div>

I need to add new series to a scatter plot and am using plots. I  
’ plt=scatter(x,y,color=“red”)’  
’ push!(plt, a,b)’

x,y,a,b, are all random 100x1 integer arrays. When I use the push! as noted above only a[1],b[1] is plotted. and it is int he same color. How do I add another series and specify its color?

Been playing with this a lot and cant seem to find my way around the plots documentation site to figure it out.

Also, with v1 upon us, what are the plotting packages of choice?

---

<div class="post-metadata">

### Author: ![LeoK987](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leok987/32/4880_2.png) [@LeoK987](https://discourse.julialang.org/u/LeoK987)
#### Post date: [September 20, 2018, 1:32am UTC](https://discourse.julialang.org/t/plots-jl-using-push-to-add-a-new-scatter-plot-series-with-a-specified-color/15206/2 "2018-09-20T01:32:57Z")

</div>

Replace push! with the following should work:

`plot!(a, b, seriestype=:scatter)`

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [September 20, 2018, 1:33am UTC](https://discourse.julialang.org/t/plots-jl-using-push-to-add-a-new-scatter-plot-series-with-a-specified-color/15206/3 "2018-09-20T01:33:58Z")

</div>

(Please [quote your code](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530).)

Do you mean

```julia
plt = scatter(x, y, color=“red”)
scatter!(a, b, c=:blue) # c is abbreviation for colour

```

Functions with `!` at the end add to a pre-existing plot.

---

<div class="post-metadata">

### Author: ![Phillip\_Sutton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phillip_sutton/32/7603_2.png) [@Phillip\_Sutton](https://discourse.julialang.org/u/Phillip_Sutton)
#### Post date: [September 20, 2018, 2:30pm UTC](https://discourse.julialang.org/t/plots-jl-using-push-to-add-a-new-scatter-plot-series-with-a-specified-color/15206/4 "2018-09-20T14:30:54Z")

</div>

This works, but is there a way for me to add back to that plot without making it the “active” plot?

e.g.

```julia
plt = scatter(x, y, color=“red”)
oplt=scatter(q,r,color="purple")
scatter!(a, b, c=:blue)

```

but I want this to scatter! on plt… Do i have to call up plt again and then scatter to it?

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [September 20, 2018, 2:32pm UTC](https://discourse.julialang.org/t/plots-jl-using-push-to-add-a-new-scatter-plot-series-with-a-specified-color/15206/5 "2018-09-20T14:32:21Z")

</div>

I think you can just add plt as the first argument to `scatter!` ?

---

<div class="post-metadata">

### Author: ![Phillip\_Sutton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phillip_sutton/32/7603_2.png) [@Phillip\_Sutton](https://discourse.julialang.org/u/Phillip_Sutton)
#### Post date: [September 20, 2018, 3:00pm UTC](https://discourse.julialang.org/t/plots-jl-using-push-to-add-a-new-scatter-plot-series-with-a-specified-color/15206/6 "2018-09-20T15:00:39Z")

</div>

Thank you! Worked like a charm.
