Hello everyone,
I am trying to plot brackets in Makie.jl while using dates as the x axis. Unfortunately it gives me an error since I can’t use Date() as an argument in bracket!().
Here is the code that causes the error :
bracket!(ax2, Date(2020, 3, 17), 620, Date(2020, 5, 11), 620, text = "Confinement", style = :curly)
Here is my full code (the error is at the end) :
using CSV, DataFrames, CairoMakie, Dates, BenchmarkTools
# Parse the string into a date
function parse_date(date_string)
v = parse.(Int, String.(split(date_string, "/")))
return Date(v[3], v[2], v[1])
end
# Calcule décès par jours
function diff(v)
diffs = zeros(Int, length(v))
diffs[1] = v[1]
for i in 2:length(v)
diffs[i] = v[i] - v[i-1]
end
return diffs
end
data = DataFrame(CSV.File("COVID_Data_2.csv"), ["date", "nombre"])
data[!, :date] = parse_date.(data[!, :date])
data[!, :evo] = diff(data[!, :nombre])
begin
f = Figure(size=(16*100, 9*100))
# Évolution
ax1 = Axis(f[1,1],
limits = (nothing, nothing, 0, 800),
ylabel = "Nombre de décès par jours",
ylabelfont = :bold
)
@views barplot!(ax1, data[!, :date], data[!, :evo])
# Morts cumulés
ax2 = Axis(f[1,1], aspect=(16/9), yaxisposition = :right,
limits = (nothing, nothing, 0, 140_000),
title = "Évolution des décès liés à la COVID du 18/03/2020 au 31/03/2023 en France métropolitaine",
titlesize = 20,
xlabel = "Date",
ylabel = "Nombre cummulés de décès (en milliers)",
xlabelfont = :bold,
ylabelfont = :bold,
yticks = ([i for i in 0:10_000:140_000], ["$i" for i in 0:10:140])
)
hidespines!(ax2)
hidexdecorations!(ax2)
@views lines!(ax2, data[!, :date], data[!, :nombre])
# Confinement
bracket!(ax2, Date(2020, 3, 17), 620, Date(2020, 5, 11), 620, text = "Confinement", style = :curly)
f
end
Thank you for your help !
