You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section describes how to visualize YAXArrays.
4
+
See also the [Plotting maps tutorial](../tutorials/plottingmaps.md) to plot geospatial data.
5
+
All [plotting capabilities](https://rafaqz.github.io/DimensionalData.jl/stable/plots) of `AbstractDimArray` apply to a `YAXArrays` as well, because every `YAXArray` is also an `AbstractDimArray`.
6
+
7
+
## Plot a YAXArrray
8
+
9
+
Create a simple YAXArray:
10
+
11
+
```@example plot
12
+
using CairoMakie
13
+
using YAXArrays
14
+
using DimensionalData
15
+
16
+
data = collect(reshape(1:20, 4, 5))
17
+
axlist = (X(1:4), Y(1:5))
18
+
a = YAXArray(axlist, data)
19
+
```
20
+
21
+
Plot the entire array:
22
+
23
+
```@example plot
24
+
plot(a)
25
+
```
26
+
27
+
This will plot a heatmap, because the array is a matrix.
28
+
29
+
Plot the first column:
30
+
31
+
```@example plot
32
+
plot(a[Y=1])
33
+
```
34
+
35
+
This results in a scatter plot, because the subarray is a vector.
36
+
37
+
## Plot a YAXArrray with CF conventions
38
+
39
+
[Climate and Forecast Metadata Conventions](https://cfconventions.org/) are used to generate appropriate labels for the plot whenever possible.
40
+
This requires the YAXArray to have metadata properties like `standard_name` and `units`.
Plot the first time step of the sea surface temperature with CF metadata:
53
+
54
+
```@example plot
55
+
plot(ds.tos[time=1])
56
+
```
57
+
58
+
Time in [Climate and Forecasting (CF) conventions](https://cfconventions.org/Data/cf-conventions/cf-conventions-1.12/cf-conventions.html#time-coordinate-units) requires conversion before plotting, e.g., to plot the sea surface temperature over time at a given location (e.g. the null island):
59
+
60
+
```@example plot
61
+
a = ds.tos[lon = Near(0), lat = Near(0)]
62
+
times = Ti(map(x -> DateTime(string(x)), a.time.val))
63
+
a = YAXArray((times,), collect(a.data), a.properties)
0 commit comments