# Ploting data

**URL:** <https://discourse.julialang.org/t/ploting-data/78167>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 20, 2022, 3:38pm UTC](https://discourse.julialang.org/t/ploting-data/78167 "2022-03-20T15:38:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahmoud](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Mahmoud](https://discourse.julialang.org/u/Mahmoud)\
**Post date:** [March 20, 2022, 3:38pm UTC](https://discourse.julialang.org/t/ploting-data/78167/1 "2022-03-20T15:38:11Z")

</div>

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:  
 ![23232](https://global.discourse-cdn.com/julialang/original/3X/6/7/674edde6fb2b2781a9eedea82273011f03111cf9.png)  
 ![lineplot](https://global.discourse-cdn.com/julialang/original/3X/4/9/49854871e2abccee7f399b5840cd2a59526c1d1c.png)

```julia
    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])
     end

```

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [March 20, 2022, 5:36pm UTC](https://discourse.julialang.org/t/ploting-data/78167/2 "2022-03-20T17:36:01Z")

</div>

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:

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

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

---

<div class="post-metadata">

**Author:** ![Mahmoud](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Mahmoud](https://discourse.julialang.org/u/Mahmoud)\
**Post date:** [March 20, 2022, 6:06pm UTC](https://discourse.julialang.org/t/ploting-data/78167/3 "2022-03-20T18:06:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [March 20, 2022, 9:38pm UTC](https://discourse.julialang.org/t/ploting-data/78167/4 "2022-03-20T21:38:09Z")

</div>

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.

### Details

`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.
