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

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?

Replace push! with the following should work:

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

(Please quote your code.)

Do you mean

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.

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

e.g.

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?

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

2 Likes

Thank you! Worked like a charm.