Search code examples
julia

Julia plotting: how to add both a single point and a list of points to a scatter plot


If I plotted the following function:

f(x::Float64) = 4 - x^2
scatter(c1p2e16, -3.0:0.1:3.0)

I would get:

enter image description here

I have also made the following vector from 2 values:

val1 = 1                           >> 1
val2 = median(map(c1p2e16, x))     >> 3
vec = [val1,val2]             

I would like to add these values to the first plot, so that some 1,3 point would show up, like:

enter image description here


Solution

  • You can just scatter! (note the exclamation mark) to add to your existing plot:

    julia> scatter(f, -3.0:0.1:3.0)
    
    julia> scatter!([1], [3], color = "green", label = "", markersize = 10)
    

    enter image description here

    EDIT: the color in your example looks more like lime actually, so maybe change that :)