@@ -250,6 +250,50 @@ viz(fig[2, 2], world.geometry, color = area.(world.geometry))
250250fig
251251```
252252
253+ ## The cbar function
254+
255+ Any vector of Julia objects implementing the ` getcolors `
256+ function from the [ Colorfy.jl] ( https://github.com/JuliaGraphics/Colorfy.jl )
257+ module can be passed to the ` color ` option of ` viz ` /` viz! ` .
258+ The final vector of colors is a function of the ` colormap ` from
259+ [ ColorSchemes.jl] ( https://github.com/JuliaGraphics/ColorSchemes.jl )
260+ and ` colorrange ` options. To reproduce this behavior in the colorbar,
261+ the framework provides the ` cbar ` function:
262+
263+ ``` {julia}
264+ grid = CartesianGrid(2, 2)
265+ vals = [1, missing, 3, 4]
266+ cmap = "cividis"
267+
268+ fig = Mke.Figure()
269+ viz(fig[1,1], grid, color = vals, colormap = cmap)
270+ cbar(fig[1,2], vals, colormap = cmap)
271+ fig
272+ ```
273+
274+ The function is similar to Makie's colorbar function, but addresses
275+ various practical challenges with ` missing ` values, units, etc.
276+ The ` colorrange ` option is useful to set the range of colors in the
277+ presence of multiple geotables:
278+
279+ ``` {julia}
280+ grid = CartesianGrid(10, 10)
281+ val1 = 1:100
282+ val2 = [1:50; 1:50]
283+
284+ fig = Mke.Figure()
285+
286+ viz(fig[1,1], grid, color = val1, colorrange = (1, 100))
287+ viz(fig[1,2], grid, color = val2, colorrange = (1, 100))
288+ cbar(fig[1,3], val1, colorrange = (1, 100))
289+
290+ viz(fig[2,1], grid, color = val1, colorrange = (1, 50))
291+ viz(fig[2,2], grid, color = val2, colorrange = (1, 50))
292+ cbar(fig[2,3], val2, colorrange = (1, 50))
293+
294+ fig
295+ ```
296+
253297## Basic viewer
254298
255299As geospatial data scientists we are often interested in quick inspection
@@ -285,10 +329,10 @@ geotable |> viewer
285329
286330::: {.callout-note}
287331
288- The ` viz/viz! ` and the ` viewer ` automatically select color schemes
332+ The ` viewer ` automatically selects a ` cbar `
289333for variables based on data science traits from the
290334[ DataScienceTraits.jl] ( https://github.com/JuliaML/DataScienceTraits.jl )
291- module. Additionally, the ` viewer ` recognizes units from the
335+ module. It also recognizes and displays units from the
292336[ Unitful.jl] ( https://github.com/PainterQubits/Unitful.jl )
293337module:
294338
@@ -300,29 +344,6 @@ geotable |> viewer
300344
301345:::
302346
303- ## Color bars
304-
305- Any vector of Julia objects implementing the ` getcolors `
306- function from the [ Colorfy.jl] ( https://github.com/JuliaGraphics/Colorfy.jl )
307- module can be passed to the ` color ` option of ` viz ` /` viz! ` .
308- The final vector of colors will be a function of the ` colormap `
309- and ` colorrange ` options.
310-
311- To reproduce this behavior in the colorbar, the framework provides
312- the ` cbar ` function. It is similar to Makie's colorbar, but addresses
313- various practical challenges with ` missing ` values, units, etc.
314-
315- ``` {julia}
316- grid = CartesianGrid(2, 2)
317- vals = [1, missing, 3, 4]
318- cmap = "cividis"
319-
320- fig = Mke.Figure()
321- viz(fig[1,1], grid, color = vals, colormap = cmap)
322- cbar(fig[1,2], vals, colormap = cmap)
323- fig
324- ```
325-
326347We are now equipped with a set of visualization functions that can
327348really improve the speed at which we explore and analyze geospatial data.
328349These functions provide a consistent set of aesthetic options that we
0 commit comments