mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-25 04:46:04 +08:00
Mark sections as branching in VegaLite introductory notebook (#1059)
This commit is contained in:
parent
b8ba2648b3
commit
d72cb5db03
1 changed files with 36 additions and 4 deletions
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
We need two libraries for plotting in Livebook:
|
We need two libraries for plotting in Livebook:
|
||||||
|
|
||||||
* The [`vega_lite`](https://github.com/elixir-nx/vega_lite)
|
* The [`vega_lite`](https://github.com/elixir-nx/vega_lite)
|
||||||
package allows us to define our graph specifications
|
package allows us to define our graph specifications
|
||||||
|
|
||||||
* The [`kino`](https://github.com/elixir-nx/kino) package
|
* The [`kino`](https://github.com/elixir-nx/kino) package
|
||||||
renders our specifications
|
renders our specifications
|
||||||
|
|
||||||
Let's install them:
|
Let's install them:
|
||||||
|
|
||||||
|
|
@ -26,6 +26,8 @@ so it's useful to alias the module as something shorter.
|
||||||
alias VegaLite, as: Vl
|
alias VegaLite, as: Vl
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Basic concepts
|
## Basic concepts
|
||||||
|
|
||||||
Composing a basic Vega-Lite graphic usually consists of the following steps:
|
Composing a basic Vega-Lite graphic usually consists of the following steps:
|
||||||
|
|
@ -46,6 +48,8 @@ Below you can find a number of example graphics for common use cases.
|
||||||
For a number of plain Vega-Lite examples you can look
|
For a number of plain Vega-Lite examples you can look
|
||||||
[here](https://vega.github.io/vega-lite/examples).
|
[here](https://vega.github.io/vega-lite/examples).
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Bar charts
|
## Bar charts
|
||||||
|
|
||||||
### Simple bar chart
|
### Simple bar chart
|
||||||
|
|
@ -116,6 +120,8 @@ Vl.new(width: [step: 12])
|
||||||
|> Vl.config(view: [stroke: nil])
|
|> Vl.config(view: [stroke: nil])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Histograms, density plots and dot plots
|
## Histograms, density plots and dot plots
|
||||||
|
|
||||||
### Histogram
|
### Histogram
|
||||||
|
|
@ -232,6 +238,8 @@ Vl.new(title: "Daily max temperatures (C) in Seattle, WA")
|
||||||
|> Vl.config(view: [stroke: nil])
|
|> Vl.config(view: [stroke: nil])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Scatter and strip plots
|
## Scatter and strip plots
|
||||||
|
|
||||||
### Scatterplot
|
### Scatterplot
|
||||||
|
|
@ -278,6 +286,8 @@ Vl.new(width: 400, height: 300)
|
||||||
|> Vl.encode_field(:shape, "Species", type: :nominal)
|
|> Vl.encode_field(:shape, "Species", type: :nominal)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Line charts
|
## Line charts
|
||||||
|
|
||||||
### Line chart
|
### Line chart
|
||||||
|
|
@ -343,6 +353,8 @@ Vl.new(width: 300, height: 150)
|
||||||
|> Vl.encode_field(:color, "key", type: :nominal, title: nil)
|
|> Vl.encode_field(:color, "key", type: :nominal, title: nil)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Area charts and streamgraphs
|
## Area charts and streamgraphs
|
||||||
|
|
||||||
### Area chart
|
### Area chart
|
||||||
|
|
@ -387,6 +399,8 @@ Vl.new(width: 400, height: 300)
|
||||||
|> Vl.encode_field(:color, "series", scale: [scheme: "category20b"])
|
|> Vl.encode_field(:color, "series", scale: [scheme: "category20b"])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Circular plots
|
## Circular plots
|
||||||
|
|
||||||
### Pie chart
|
### Pie chart
|
||||||
|
|
@ -437,6 +451,8 @@ Vl.new()
|
||||||
|> Vl.config(view: [stroke: nil])
|
|> Vl.config(view: [stroke: nil])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Calculations
|
## Calculations
|
||||||
|
|
||||||
### Layering rolling averages over raw values
|
### Layering rolling averages over raw values
|
||||||
|
|
@ -491,6 +507,8 @@ Vl.new(width: 400, height: 300)
|
||||||
])
|
])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Composite marks
|
## Composite marks
|
||||||
|
|
||||||
### Error bars showing standard deviation
|
### Error bars showing standard deviation
|
||||||
|
|
@ -542,6 +560,8 @@ Vl.new(width: 400, height: 300)
|
||||||
])
|
])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Box plots
|
## Box plots
|
||||||
|
|
||||||
### Box plot with min/max whiskers
|
### Box plot with min/max whiskers
|
||||||
|
|
@ -559,6 +579,8 @@ Vl.new(width: 400, height: 300)
|
||||||
|> Vl.encode_field(:y, "Body Mass (g)", type: :quantitative, scale: [zero: false])
|
|> Vl.encode_field(:y, "Body Mass (g)", type: :quantitative, scale: [zero: false])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Faceting
|
## Faceting
|
||||||
|
|
||||||
### Trellis bar chart
|
### Trellis bar chart
|
||||||
|
|
@ -618,6 +640,8 @@ Vl.new(name: "Trellis Barley", height: [step: 12])
|
||||||
|> Vl.encode_field(:color, "year", type: :nominal)
|
|> Vl.encode_field(:color, "year", type: :nominal)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Repeated graphics
|
## Repeated graphics
|
||||||
|
|
||||||
### Repeated layer
|
### Repeated layer
|
||||||
|
|
@ -696,6 +720,8 @@ Vl.new()
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Layering
|
## Layering
|
||||||
|
|
||||||
### Layered charts with separate scales
|
### Layered charts with separate scales
|
||||||
|
|
@ -731,6 +757,8 @@ Vl.new(width: 400, height: 300)
|
||||||
|> Vl.resolve(:scale, y: :independent)
|
|> Vl.resolve(:scale, y: :independent)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Concatenation
|
## Concatenation
|
||||||
|
|
||||||
### Arbitrary charts
|
### Arbitrary charts
|
||||||
|
|
@ -759,6 +787,8 @@ Vl.new()
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Maps (geographic displays)
|
## Maps (geographic displays)
|
||||||
|
|
||||||
### Projection
|
### Projection
|
||||||
|
|
@ -805,6 +835,8 @@ Vl.new(width: 500, height: 300)
|
||||||
|> Vl.config(view: [stroke: nil])
|
|> Vl.config(view: [stroke: nil])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- livebook:{"branch_parent_index":0} -->
|
||||||
|
|
||||||
## Interactive graphics
|
## Interactive graphics
|
||||||
|
|
||||||
### Overview and detail
|
### Overview and detail
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue