I have successfully created a time series plot using timeseries.jl, with Version 1.5.3 (2020-11-09), in Juno, installed with JuliaPro, with the following code
ATTEMPT 1:
using IterableTables
using DataFrames
using CSV
using Dates
using TimeSeries
using Plots
myfile="test2.csv"
dmft = dateformat"d/m/yyyy HH:MM:SS"
df = DataFrame(CSV.File(joinpath(@__DIR__,myfile); dateformat=dmft))
println(first(df,10))
ta = TimeArray(df; timestamp = :Date)
println(colnames(ta))
display(plot(ta[:Col3]))
plot omitted as new user cannot add more than one media
with the following output in my REPL
10Γ5 DataFrame
β Row β Date β Col1 β Col2 β Col3 β Col4 β
β β DateTime β Float64 β Float64 β Float64 β Float64 β
βββββββΌββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β 1 β 2020-08-10T00:00:00 β 507.28 β 181.34 β 1532.96 β 183.16 β
β 2 β 2020-08-10T00:01:00 β 507.29 β 181.34 β 1532.95 β 183.16 β
β 3 β 2020-08-10T00:02:00 β 507.27 β 181.34 β 1532.94 β 183.16 β
β 4 β 2020-08-10T00:03:00 β 507.28 β 181.34 β 1532.97 β 183.16 β
β 5 β 2020-08-10T00:04:00 β 507.29 β 181.33 β 1532.97 β 183.16 β
β 6 β 2020-08-10T00:05:00 β 507.29 β 181.33 β 1532.96 β 183.16 β
β 7 β 2020-08-10T00:06:00 β 507.27 β 181.33 β 1532.95 β 183.16 β
β 8 β 2020-08-10T00:07:00 β 507.28 β 181.33 β 1532.96 β 183.16 β
β 9 β 2020-08-10T00:08:00 β 507.27 β 181.33 β 1532.95 β 183.16 β
β 10 β 2020-08-10T00:09:00 β 507.28 β 181.32 β 1532.96 β 183.16 β
[:Col1, :Col2, :Col3, :Col4]
Unfortunately, it came out as an image where if I zoom the resolution is not high as can be seen below.
WHAT I LIKE TO ACHIEVE:
Ideally, I would prefer a high resolution image as below which i can zoomed in properly using Shift and left mouse button.
Image omitted as new user cannot have more than one image
the dataframe for the above image looks like below.
julia> print(first(mydf2,10))
10Γ8 DataFrame
β Row β ticker β timestamp β Open β High β Low β Close β AdjClose β Volume β
β β String β Date β Float64 β Float64 β Float64 β Float64 β Float64 β Float64 β
βββββββΌβββββββββΌβββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌβββββββββββΌββββββββββββ€
β 1 β MSFT β 2010-12-27 β 28.12 β 28.2 β 27.88 β 28.07 β 22.3176 β 2.16528e7 β
β 2 β MSFT β 2010-12-28 β 27.97 β 28.17 β 27.96 β 28.01 β 22.2699 β 2.30422e7 β
β 3 β MSFT β 2010-12-29 β 27.94 β 28.12 β 27.88 β 27.97 β 22.2381 β 1.95025e7 β
β 4 β MSFT β 2010-12-30 β 27.92 β 28.0 β 27.78 β 27.85 β 22.1427 β 2.07861e7 β
β 5 β MSFT β 2010-12-31 β 27.8 β 27.92 β 27.63 β 27.91 β 22.1904 β 2.4752e7 β
β 6 β MSFT β 2011-01-03 β 28.05 β 28.18 β 27.92 β 27.98 β 22.2461 β 5.34438e7 β
β 7 β MSFT β 2011-01-04 β 27.94 β 28.17 β 27.85 β 28.09 β 22.3335 β 5.44056e7 β
β 8 β MSFT β 2011-01-05 β 27.9 β 28.01 β 27.77 β 28.0 β 22.262 β 5.89987e7 β
β 9 β MSFT β 2011-01-06 β 28.04 β 28.85 β 27.86 β 28.82 β 22.9139 β 8.80263e7 β
β 10 β MSFT β 2011-01-07 β 28.64 β 28.74 β 28.25 β 28.6 β 22.739 β 7.3762e7 β
using data from MarketData.jl with the following code to plot:
using Gadfly
display(plot(mydf2,x="timestamp",y="AdjClose", Geom.line))
ATTEMPT 2:
I tried with my first dataseries to achieve similar results, just ignoring the TimeArray (since it didnt help in Attempt 1), and got the following error
myfile="test2.csv"
df = DataFrame(CSV.File(joinpath(@__DIR__,myfile)))
println(first(df,10))
display(plot(df,x="Date",y="Col3", Geom.line))
I got the following dataframe and error message:
10Γ5 DataFrame
β Row β Date β Col1 β Col2 β Col3 β Col4 β
β β DateTime β Float64 β Float64 β Float64 β Float64 β
βββββββΌββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β 1 β 2020-08-10T00:00:00 β 507.28 β 181.34 β 1532.96 β 183.16 β
β 2 β 2020-08-10T00:01:00 β 507.29 β 181.34 β 1532.95 β 183.16 β
β 3 β 2020-08-10T00:02:00 β 507.27 β 181.34 β 1532.94 β 183.16 β
β 4 β 2020-08-10T00:03:00 β 507.28 β 181.34 β 1532.97 β 183.16 β
β 5 β 2020-08-10T00:04:00 β 507.29 β 181.33 β 1532.97 β 183.16 β
β 6 β 2020-08-10T00:05:00 β 507.29 β 181.33 β 1532.96 β 183.16 β
β 7 β 2020-08-10T00:06:00 β 507.27 β 181.33 β 1532.95 β 183.16 β
β 8 β 2020-08-10T00:07:00 β 507.28 β 181.33 β 1532.96 β 183.16 β
β 9 β 2020-08-10T00:08:00 β 507.27 β 181.33 β 1532.95 β 183.16 β
β 10 β 2020-08-10T00:09:00 β 507.28 β 181.32 β 1532.96 β 183.16 β
ERROR: LoadError: Cannot convert DataFrame to series data for plotting
ATTEMPT 3:
Since it is in DateTime format, I wonder why that is an issue. Ok so I tried something different now, not changing the format when loading the data, and still not using the TimeArray:
myfile="test2.csv"
# dmft = dateformat"d/m/yyyy HH:MM:SS"
df = DataFrame(CSV.File(joinpath(@__DIR__,myfile))) # dateformat=dmft removed
println(first(df,10))
display(plot(df,x="Date",y="Col3", Geom.line))
but I still got this result:
10Γ5 DataFrame
β Row β Date β Col1 β Col2 β Col3 β Col4 β
β β String β Float64 β Float64 β Float64 β Float64 β
βββββββΌβββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β 1 β 10/8/2020 0:00 β 507.28 β 181.34 β 1532.96 β 183.16 β
β 2 β 10/8/2020 0:01 β 507.29 β 181.34 β 1532.95 β 183.16 β
β 3 β 10/8/2020 0:02 β 507.27 β 181.34 β 1532.94 β 183.16 β
β 4 β 10/8/2020 0:03 β 507.28 β 181.34 β 1532.97 β 183.16 β
β 5 β 10/8/2020 0:04 β 507.29 β 181.33 β 1532.97 β 183.16 β
β 6 β 10/8/2020 0:05 β 507.29 β 181.33 β 1532.96 β 183.16 β
β 7 β 10/8/2020 0:06 β 507.27 β 181.33 β 1532.95 β 183.16 β
β 8 β 10/8/2020 0:07 β 507.28 β 181.33 β 1532.96 β 183.16 β
β 9 β 10/8/2020 0:08 β 507.27 β 181.33 β 1532.95 β 183.16 β
β 10 β 10/8/2020 0:09 β 507.28 β 181.32 β 1532.96 β 183.16 β
ERROR: LoadError: Cannot convert DataFrame to series data for plotting
I suspect the issue is with the Date or DateTime, but I havenβt been able to nail it down. There was a post on plotting the time series data, but using String instead. Gadfly.jl : How to plot date time based? resulting in my attempt below:
ATTEMPT 4:
myfile="test2.csv"
dmft = dateformat"d/m/yyyy HH:MM:SS"
df = DataFrame(CSV.File(joinpath(@__DIR__,myfile); dateformat=dmft)) # historical data for the ticker
dt = Array(df.Date)
dt_str = Array(String,length(dt))
for i=1:length(dt)
dt_str[i] = string(dt[i]);
end
with the following error message:
ERROR: LoadError: MethodError: no method matching Array(::Type{String}, ::Int64)
This is a small snippet of my csv, in case you want to try it out.
Date,Col1,Col2,Col3,Col4
10/8/2020 0:00,507.28,181.34,1532.96,183.16
10/8/2020 0:01,507.29,181.34,1532.95,183.16
10/8/2020 0:02,507.27,181.34,1532.94,183.16
10/8/2020 0:03,507.28,181.34,1532.97,183.16
10/8/2020 0:04,507.29,181.33,1532.97,183.16
10/8/2020 0:05,507.29,181.33,1532.96,183.16
10/8/2020 0:06,507.27,181.33,1532.95,183.16
10/8/2020 0:07,507.28,181.33,1532.96,183.16
10/8/2020 0:08,507.27,181.33,1532.95,183.16
10/8/2020 0:09,507.28,181.32,1532.96,183.16
10/8/2020 0:10,507.29,181.32,1532.97,183.16
10/8/2020 0:11,507.28,181.33,1532.94,183.16
10/8/2020 0:12,507.27,181.33,1532.96,183.16
10/8/2020 0:13,507.31,181.33,1532.96,183.17
I am a newcomer to Julia, any beginnerβs level guide is most appreciated.