Skip to content

Time series plot with period data type #474

Open
@WolfgangWeiss

Description

@WolfgangWeiss

Plotting time series with the data type Date works as expected

df1 = DataFrame(a=Date[Date("2023-10-20"), Date("2023-10-21"), Date("2023-10-22"), Date("2023-10-23")], b=Int[1, 2, 3, 2])
p1 = plot(df1, x=:a, y=:b)

Result:
plot-1

But when using a Period data type such as Millisecond, Day, CompoundPeriod, ... the plot will appear blank

df2 = DataFrame(b=Millisecond[Millisecond(1000), Millisecond(2000), Millisecond(3000), Millisecond(4000)], a=Int[1, 2, 3, 2])
p2 = plot(df2, x=:a, y=:b)
startDate = Day(0)
df3 = DataFrame(b=Dates.CompoundPeriod[Dates.CompoundPeriod(startDate), Dates.CompoundPeriod(startDate + Day(1)), Dates.CompoundPeriod(startDate + Day(2)),Dates.CompoundPeriod(startDate + Day(3))], a=Int[1, 2, 3, 2])
p3 = plot(df3, x=:a, y=:b)

Result:
plot-2

Version info

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, ivybridge)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS =
julia> using Pkg; pkg"status"
Status `... .julia\environments\v1.9\Project.toml`
  [336ed68f] CSV v0.10.11
  [a93c6f00] DataFrames v1.6.1
  [864edb3b] DataStructures v0.18.15
  [f0f68f2c] PlotlyJS v0.18.11
  [2913bbd2] StatsBase v0.34.2
  [fdbf4ff8] XLSX v0.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions