Skip to content

Commit 2fd0a69

Browse files
committed
aog simple analysis
1 parent edca792 commit 2fd0a69

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

docs/src/tutorials/plottingmaps.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,19 @@ mesh!(ax, sphere; color = ds'[end:-1:1,:], shading=false,
9393
colormap = :seaborn_icefire_gradient)
9494
zoom!(ax.scene, cameracontrols(ax.scene), 0.5)
9595
rotate!(ax.scene, 2.5)
96-
fig
96+
display(fig, update=false)
9797
````
9898

99-
# AlgebraOfGraphics.jl
99+
## AlgebraOfGraphics.jl
100+
101+
::: info
102+
103+
From [DimensionalData docs](https://rafaqz.github.io/DimensionalData.jl/stable/plots#algebraofgraphics-jl) :
104+
105+
**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.
106+
107+
:::
100108

101-
> [!NOTE]
102-
> From [DimensionalData docs](https://rafaqz.github.io/DimensionalData.jl/stable/plots#algebraofgraphics-jl) :
103-
>
104-
> **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.
105109

106110
````@example AoG
107111
using YAXArrays, Zarr, Dates
@@ -116,13 +120,15 @@ let's continue using the cmip6 dataset
116120
````@example AoG
117121
store ="gs://cmip6/CMIP6/ScenarioMIP/DKRZ/MPI-ESM1-2-HR/ssp585/r1i1p1f1/3hr/tas/gn/v20190710/"
118122
g = open_dataset(zopen(store, consolidated=true))
119-
c = g["tas"]
123+
c = g["tas"];
124+
nothing # hide
120125
````
121126

122127
and let's focus on the first time step:
123128

124129
````@example AoG
125-
dim_data = readcubedata(c[time=1]) # read into memory first!
130+
dim_data = readcubedata(c[time=1]); # read into memory first!
131+
nothing # hide
126132
````
127133

128134
and now plot
@@ -131,6 +137,12 @@ and now plot
131137
data(dim_data) * mapping(:lon, :lat; color=:value) * visual(Scatter) |> draw
132138
````
133139

140+
::: warning
141+
142+
Note that we are using a `Scatter` type per point and not the `Heatmap` one. There are workarounds for this, albeit cumbersome, so for now, let's keep this simpler syntax in mind along with the current approach being used.
143+
144+
:::
145+
134146
set other attributes
135147

136148
````@example AoG
@@ -139,7 +151,7 @@ draw(plt * visual(Scatter, marker=:rect), scales(Color = (; colormap = :plasma))
139151
axis = (width = 600, height = 400, limits=(0, 360, -90, 90)))
140152
````
141153

142-
## Faceting
154+
### Faceting
143155

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

@@ -177,6 +189,19 @@ draw(plt * visual(Lines); figure=(; size=(650,400)))
177189
or faceting them
178190

179191
````@example AoG
180-
plt = data(dim_data[lon=50..59]) * mapping(:lat, :value => "tas"; color=:value => "tas", layout = :lon => nonnumeric)
192+
plt = data(dim_data[lon=50..59]) * mapping(:lat, :value => "tas"; color=:value => "tas",
193+
layout = :lon => nonnumeric)
181194
draw(plt * visual(Lines); figure=(; size=(650,400)))
182-
````
195+
````
196+
197+
### Analysis
198+
199+
Basic statistical [analysis](https://aog.makie.org/stable/generated/analyses/) can also be done, for example:
200+
201+
````@example AoG
202+
specs = data(dim_data[lat=50..55]) * mapping(:lon, :value => "tas"; color=:lat => nonnumeric)
203+
specs *= (smooth() + visual(Scatter))
204+
draw(specs; figure=(; size=(700,400)))
205+
````
206+
207+
For more, visit [AlgebraOfGraphics.jl](https://aog.makie.org/stable/).

0 commit comments

Comments
 (0)