From 331ec197f413159ef10b4e86a2201711eb5c6ff6 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 30 Aug 2024 10:41:44 +0200 Subject: [PATCH 1/5] Remove unnecessary time tick code in msc tutorial This is not needed anymore since Makie can handle the time axis natively now. --- docs/src/tutorials/mean_seasonal_cycle.md | 32 +++-------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/docs/src/tutorials/mean_seasonal_cycle.md b/docs/src/tutorials/mean_seasonal_cycle.md index 770b7f81..03d627f4 100644 --- a/docs/src/tutorials/mean_seasonal_cycle.md +++ b/docs/src/tutorials/mean_seasonal_cycle.md @@ -1,4 +1,4 @@ -# Mean Seasonal Cycle for a sigle pixel +# Mean Seasonal Cycle for a single pixel ````@example mean_season using CairoMakie @@ -21,34 +21,12 @@ var = @. sin(x) + 0.1 * randn() nothing # hide ```` -````@example mean_season -lines(1:length(t), var; color = :purple, linewidth=1.25, - axis=(; xlabel="Time", ylabel="Variable"), - figure = (; resolution = (600,400)) - ) -```` - -Currently makie doesn't support time axis natively, but the following function can do the work for now. - -````@example mean_season -function time_ticks(dates; frac=8) - tempo = string.(dates) - lentime = length(tempo) - slice_dates = range(1, lentime, step=lentime ÷ frac) - return slice_dates, tempo[slice_dates] -end -xpos, ticks = time_ticks(t; frac=8) -nothing # hide -```` - -In order to apply the previous output, we split the plotting function into his 3 components, `figure`, `axis` and `plotted object`, namely ````@example mean_season -fig, ax, obj = lines(1:length(t), var; color = :purple, linewidth=1.25, +fig, ax, obj = lines(t, var; color = :purple, linewidth=1.25, axis=(; xlabel="Time", ylabel="Variable"), - figure = (; resolution = (600,400)) + figure = (; size = (600,400)) ) -ax.xticks = (xpos, ticks) ax.xticklabelrotation = π / 4 ax.xticklabelalign = (:right, :center) fig @@ -90,11 +68,10 @@ TODO: Apply the new groupby funtion from DD ### Plot results: mean seasonal cycle ````@example mean_season -xpos, ticks = time_ticks(t[1:365]; frac=8) fig, ax, obj = lines(1:365, var[1:365]; label="2021", color=:black, linewidth=2.0, linestyle=:dot, - axis = (; xlabel="Time", ylabel="Variable"), + axis = (; xlabel="Day of Year", ylabel="Variable"), figure=(; size = (600,400)) ) lines!(1:365, var[366:730], label="2022", color=:brown, @@ -106,5 +83,4 @@ ax.xticks = (xpos, ticks) ax.xticklabelrotation = π / 4 ax.xticklabelalign = (:right, :center) fig -current_figure() ```` \ No newline at end of file From f4d3c057635cd262494f38579355dcb7521f730a Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 30 Aug 2024 12:11:04 +0200 Subject: [PATCH 2/5] add current_figure() to last example --- docs/src/tutorials/mean_seasonal_cycle.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/tutorials/mean_seasonal_cycle.md b/docs/src/tutorials/mean_seasonal_cycle.md index 03d627f4..21b934a0 100644 --- a/docs/src/tutorials/mean_seasonal_cycle.md +++ b/docs/src/tutorials/mean_seasonal_cycle.md @@ -30,6 +30,7 @@ fig, ax, obj = lines(t, var; color = :purple, linewidth=1.25, ax.xticklabelrotation = π / 4 ax.xticklabelalign = (:right, :center) fig +current_figure() ```` ### Define the cube From 3092cc6e26f9a6410298b927f9f0a926f6061b3b Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 30 Aug 2024 12:12:28 +0200 Subject: [PATCH 3/5] Add current_figure at the correct position --- docs/src/tutorials/mean_seasonal_cycle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/tutorials/mean_seasonal_cycle.md b/docs/src/tutorials/mean_seasonal_cycle.md index 21b934a0..d0cee23c 100644 --- a/docs/src/tutorials/mean_seasonal_cycle.md +++ b/docs/src/tutorials/mean_seasonal_cycle.md @@ -30,7 +30,6 @@ fig, ax, obj = lines(t, var; color = :purple, linewidth=1.25, ax.xticklabelrotation = π / 4 ax.xticklabelalign = (:right, :center) fig -current_figure() ```` ### Define the cube @@ -84,4 +83,5 @@ ax.xticks = (xpos, ticks) ax.xticklabelrotation = π / 4 ax.xticklabelalign = (:right, :center) fig +current_figure() ```` \ No newline at end of file From 0b3ba7eee1479b0fb272f237beeff6935176e107 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 30 Aug 2024 12:37:17 +0200 Subject: [PATCH 4/5] Remove empty line --- docs/src/tutorials/mean_seasonal_cycle.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/tutorials/mean_seasonal_cycle.md b/docs/src/tutorials/mean_seasonal_cycle.md index d0cee23c..e21ee900 100644 --- a/docs/src/tutorials/mean_seasonal_cycle.md +++ b/docs/src/tutorials/mean_seasonal_cycle.md @@ -68,7 +68,6 @@ TODO: Apply the new groupby funtion from DD ### Plot results: mean seasonal cycle ````@example mean_season - fig, ax, obj = lines(1:365, var[1:365]; label="2021", color=:black, linewidth=2.0, linestyle=:dot, axis = (; xlabel="Day of Year", ylabel="Variable"), From 3501fb89effd45ad82b364f2f7d6d2496c033599 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 30 Aug 2024 14:18:17 +0200 Subject: [PATCH 5/5] Remove xticks change --- docs/src/tutorials/mean_seasonal_cycle.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/tutorials/mean_seasonal_cycle.md b/docs/src/tutorials/mean_seasonal_cycle.md index e21ee900..aab984e9 100644 --- a/docs/src/tutorials/mean_seasonal_cycle.md +++ b/docs/src/tutorials/mean_seasonal_cycle.md @@ -78,7 +78,6 @@ lines!(1:365, var[366:730], label="2022", color=:brown, ) lines!(1:365, msc[:,1]; label="MSC", color=:dodgerblue, linewidth=2.5) axislegend() -ax.xticks = (xpos, ticks) ax.xticklabelrotation = π / 4 ax.xticklabelalign = (:right, :center) fig