Ploting data

I have the scattered data image
is there anyway to represent it in lines like second image?
this is the code that I used to generate the image:

    for i in 1:100
    # code to update days,numberofhealthy ,numberofinfected ,and numberofrecovered 
    scatter!((days,[numberofhealthy numberofinfected numberofrecovered 
     numberofsick]),legend=false,color = [:blue :green :gold :red])

Welcome to Julia and the Julia discourse!

Here’s some tips, among others how to format code, to make it a little easier to read what you’ve done so far:

What do you want the plot to look like, i.e. what does your code not accomplish?

Thanks for reply.
My code draws the second image(scattered image)
I want to plot something like the first image (lines)
You have to know that at each loop step the points values are updated so they give this shape.

If at every step your vectors contain all of the values so far, you can just replace scatter! by plot.

And unless you are animating it, you probably want to put the plot command outside the loop.


scatter!(...) is an alias for plot!(...; seriestype=:scatter), but you want the default seriestype, :line.

The version of these commands with a ! are updating, so they leave whatever was previously drawn in place. This is not what you want since you are adding all of the points every time.

1 Like