Skip to content

Commit

Permalink
aog examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarusA committed Dec 17, 2024
1 parent b00461b commit 125fd7a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
3 changes: 1 addition & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[deps]
AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"
CFTime = "179af706-886a-5703-950a-314cd64e0468"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand All @@ -27,7 +27,6 @@ PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
SkipNan = "aed68c70-c8b0-4309-8cd1-d392a74f991a"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
WeightedOnlineStats = "bbac0a1f-7c9d-5672-960b-c6ca726e5d5d"
YAXArrayBase = "90b8fcef-0c2d-428d-9c56-5f86629e9d14"
YAXArrays = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c"
Expand Down
61 changes: 61 additions & 0 deletions docs/src/tutorials/plottingmaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,66 @@ fig
>
> **AlgebraOfGraphics.jl** is a high-level plotting library built on top of Makie.jl that provides a declarative algebra for creating complex visualizations, similar to **ggplot2**'s "grammar of graphics" in R. It allows you to construct plots using algebraic operations like **(*)** and **(+)**, making it easy to create sophisticated graphics with minimal code.
````@example plots
using GLMakie
using AlgebraOfGraphics
GLMakie.activate!()
# let's continue using the cmip6 dataset
c = g["tas"]
````


````@example plots
# let's continue using the cmip6 dataset
c = g["tas"]
````

and let's focus on the first time step:

````@example plots
dim_data = c[time=1][:,:] # read into memory first!
plt = data(dim_data) * mapping(:lon, :lat; color=:value) * visual(Scatter, marker=:rect)
draw(plt)
````

and now plot

````@example plots
data(dim_data) * mapping(:lon, :lat; color=:value) * visual(Scatter) |> draw
````

set other attributes

````@example plots
plt = data(dim_data) * mapping(:lon, :lat; color=:value)
draw(plt * visual(Scatter, marker=:rect), scales(Color = (; colormap = :plasma));
axis = (width = 600, height = 400, limits=(0, 360, -90, 90)))
````

## Faceting

For this let's consider more time steps from our dataset:

````@example plots
using Dates
dim_time = c[time=DateTime("2015-01-01") .. DateTime("2015-01-01T21:00:00")] # subset 7 t steps
````

````@example plots
dim_time = dim_time[:,:,:]; # read into memory first!
nothing # hide
````

````@example plots
plt = data(dim_time) * mapping(:lon, :lat; color = :value, layout = :time => nonnumeric)
draw(plt * visual(Scatter, marker=:rect))
````

again, let's add some additional attributes

````@example plots
plt = data(dim_time) * mapping(:lon, :lat; color = :value, layout = :time => nonnumeric)
draw(plt * visual(Scatter, marker=:rect), scales(Color = (; colormap = :magma));
axis = (; limits=(0, 360, -90, 90)),
figure=(; size=(900,600)))
````

0 comments on commit 125fd7a

Please sign in to comment.