View Source Tucan.View (tucan v0.4.1)
Helper utilities for customizing the plot view.
Summary
Functions
Sets the background color of the visualization canvas.
Sets the background color of the view.
Functions
@spec set_background(vl :: VegaLite.t(), color :: String.t()) :: VegaLite.t()
Sets the background color of the visualization canvas.
Examples
Tucan.scatter(:iris, "sepal_width", "sepal_length")
|> Tucan.View.set_background("#fcffde")
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","background":"#fcffde","data":{"url":"https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv"},"encoding":{"x":{"field":"sepal_width","scale":{"zero":false},"type":"quantitative"},"y":{"field":"sepal_length","scale":{"zero":false},"type":"quantitative"}},"mark":{"fillOpacity":1,"type":"point"}}
@spec set_view_background(vl :: VegaLite.t(), color :: String.t()) :: VegaLite.t()
Sets the background color of the view.
set_background/2
defines the background of the whole visualization canvas. Meanwhile,
the view property of a single-view or layer specification can define the background of
the view.
Examples
Two concatenated plots with different view backgrounds and an overall canvas background.
Tucan.hconcat([
Tucan.scatter(:iris, "sepal_width", "sepal_length")
|> Tucan.View.set_view_background("#e6fae1"),
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.View.set_view_background("#facbc5")
])
|> Tucan.View.set_background("#fcffde")
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","background":"#fcffde","hconcat":[{"data":{"url":"https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv"},"encoding":{"x":{"field":"sepal_width","scale":{"zero":false},"type":"quantitative"},"y":{"field":"sepal_length","scale":{"zero":false},"type":"quantitative"}},"mark":{"fillOpacity":1,"type":"point"},"view":{"fill":"#e6fae1"}},{"data":{"url":"https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv"},"encoding":{"x":{"field":"petal_width","scale":{"zero":false},"type":"quantitative"},"y":{"field":"petal_length","scale":{"zero":false},"type":"quantitative"}},"mark":{"fillOpacity":1,"type":"point"},"view":{"fill":"#facbc5"}}]}