# How to add Another Line Plot to DataFrame and CSV Plot?

**URL:** https://discourse.julialang.org/t/how-to-add-another-line-plot-to-dataframe-and-csv-plot/94910
**Category:** General Usage
**Tags:** plotting
**Created:** [February 20, 2023, 10:37am UTC](https://discourse.julialang.org/t/how-to-add-another-line-plot-to-dataframe-and-csv-plot/94910 "2023-02-20T10:37:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)
#### Post date: [February 20, 2023, 10:37am UTC](https://discourse.julialang.org/t/how-to-add-another-line-plot-to-dataframe-and-csv-plot/94910/1 "2023-02-20T10:37:02Z")

</div>

Hi all,

I am trying to add another plot of Book Value per Share.  
It is following this tutorial:  
[https://www.juliabloggers.com/using-julia-for-data-science-part-03-plotting/](https://www.juliabloggers.com/using-julia-for-data-science-part-03-plotting/)

this is my code:

```julia
using CSV, Dates, DataFrames, Plots, Plots.PlotMeasures, RollingFunctions

fileadhi = "./csv/IDX-Stocks/ADHI Historical Data.csv"

dfadhi = CSV.read(fileadhi, DataFrame)

dfadhi.Price .= parse.(Float64, replace.(dfadhi.Price, "," => ""))
dfadhi[!,"Change %"] .= parse.(Float64, replace.(dfadhi[!,"Change %"], "%" => ""))

dfadhi.Dates = Date.(dfadhi.Date, "mm/dd/yyyy")
tick_years = Date.(unique(Dates.year.(dfadhi.Dates)))
DateTick = Dates.format.(tick_years, "yy")
xlimsadhi = extrema([tick_years; dfadhi.Dates])

plot(dfadhi.Dates, dfadhi.Price, title="",
    xticks=(tick_years,DateTick), xlims=xlimsadhi,
    label="Adhi Karya (Price)", xlabel="", ylabel="")

# Set Book Value per Share
x = [04/01/2004 04/01/2008];
y = [300 400];
plot!(x,y, label="Book Value per Share")

```

But, the plot does not show:  
 ![Capture d’écran_2023-02-20_17-27-49](https://global.discourse-cdn.com/julialang/original/3X/4/7/47aede26b8ca6628c245cdd76ccbe2f979b343bb.png)

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [February 20, 2023, 12:17pm UTC](https://discourse.julialang.org/t/how-to-add-another-line-plot-to-dataframe-and-csv-plot/94910/2 "2023-02-20T12:17:37Z")

</div>

> [@Freya\_the\_Goddess](#):
>
> ```julia
> x = [04/01/2004 04/01/2008];
> y = [300 400];
> 
> ```

These are 1x2 matrices rather than column vectors, you want to either create vectors (`[300, 400]`, note the comma) or transpose the matrices (`plot(x', y')`)

Your other problem is that `x` is not what you think it is:

```julia
julia> x
1×2 Matrix{Float64}:
 0.00199601 0.00199203

```

When you do `4/1/2004` you are are just dividing 4 by 1 and then the result (i.e. 4) by 2004, which gives 0.01996. Dates are created either from strings or by directly passing year, month, and day to the constructor:

```julia
julia> using Dates

julia> Date("04/01/2004", "d/m/y")
2004-01-04

julia> Date(2004, 1, 4)
2004-01-04

```

---

<div class="post-metadata">

### Author: ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)
#### Post date: [February 21, 2023, 9:10am UTC](https://discourse.julialang.org/t/how-to-add-another-line-plot-to-dataframe-and-csv-plot/94910/3 "2023-02-21T09:10:35Z")

</div>

I see it is wrong format then, thanks a lot! now it is working!

Sorry for asking too many questions in Discourse, it is curiosity that kills the cat.
