Hi all, can someone help me understand why my code is not able to produce a plot with custom xticks for a Date
x-axis? I would like to plot the time axis using ticks that are spaced out more widely.
using DataFrames, StatsPlots, Plots, Dates, Distributions
sample_df = DataFrame(
date = [Date(2019,1,1) + Day(i) for i in 0:90],
)
sample_df[:, :value1] .= rand(Poisson(10), nrow(sample_df))
sample_df[:, :value2] .= rand(Poisson(50), nrow(sample_df))
sample_df = stack(sample_df, [:value1, :value2])
@df sample_df groupedbar(
:date, :value, group=:variable, bar_position=:dodge
)
date_ticks = round.(sample_df.date, Week(2)) |> unique
@df sample_df groupedbar(
:date, :value, group=:variable, bar_position=:dodge,
xticks=(date_ticks, Dates.format.(date_ticks, "mm/yyyy")), xlim=extrema(date_ticks), xrot=60
)