Skip to content

Commit 125fd7a

Browse files
committed
aog examples
1 parent b00461b commit 125fd7a

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

docs/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[deps]
2+
AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
23
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
34
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
4-
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"
55
CFTime = "179af706-886a-5703-950a-314cd64e0468"
66
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
@@ -27,7 +27,6 @@ PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
2727
SkipNan = "aed68c70-c8b0-4309-8cd1-d392a74f991a"
2828
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
2929
TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
30-
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
3130
WeightedOnlineStats = "bbac0a1f-7c9d-5672-960b-c6ca726e5d5d"
3231
YAXArrayBase = "90b8fcef-0c2d-428d-9c56-5f86629e9d14"
3332
YAXArrays = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c"

docs/src/tutorials/plottingmaps.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,66 @@ fig
103103
>
104104
> **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.
105105
106+
````@example plots
107+
using GLMakie
108+
using AlgebraOfGraphics
109+
GLMakie.activate!()
110+
# let's continue using the cmip6 dataset
111+
c = g["tas"]
112+
````
106113

107114

115+
````@example plots
116+
# let's continue using the cmip6 dataset
117+
c = g["tas"]
118+
````
119+
120+
and let's focus on the first time step:
121+
122+
````@example plots
123+
dim_data = c[time=1][:,:] # read into memory first!
124+
plt = data(dim_data) * mapping(:lon, :lat; color=:value) * visual(Scatter, marker=:rect)
125+
draw(plt)
126+
````
127+
128+
and now plot
129+
130+
````@example plots
131+
data(dim_data) * mapping(:lon, :lat; color=:value) * visual(Scatter) |> draw
132+
````
133+
134+
set other attributes
135+
136+
````@example plots
137+
plt = data(dim_data) * mapping(:lon, :lat; color=:value)
138+
draw(plt * visual(Scatter, marker=:rect), scales(Color = (; colormap = :plasma));
139+
axis = (width = 600, height = 400, limits=(0, 360, -90, 90)))
140+
````
141+
142+
## Faceting
143+
144+
For this let's consider more time steps from our dataset:
145+
146+
````@example plots
147+
using Dates
148+
dim_time = c[time=DateTime("2015-01-01") .. DateTime("2015-01-01T21:00:00")] # subset 7 t steps
149+
````
150+
151+
````@example plots
152+
dim_time = dim_time[:,:,:]; # read into memory first!
153+
nothing # hide
154+
````
155+
156+
````@example plots
157+
plt = data(dim_time) * mapping(:lon, :lat; color = :value, layout = :time => nonnumeric)
158+
draw(plt * visual(Scatter, marker=:rect))
159+
````
160+
161+
again, let's add some additional attributes
162+
163+
````@example plots
164+
plt = data(dim_time) * mapping(:lon, :lat; color = :value, layout = :time => nonnumeric)
165+
draw(plt * visual(Scatter, marker=:rect), scales(Color = (; colormap = :magma));
166+
axis = (; limits=(0, 360, -90, 90)),
167+
figure=(; size=(900,600)))
168+
````

0 commit comments

Comments
 (0)