File: line_chart_with_generator.py

package info (click to toggle)
python-altair 5.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,952 kB
  • sloc: python: 25,649; sh: 14; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 463 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""
Line Chart with Sequence Generator
----------------------------------
This examples shows how to create multiple lines using the sequence generator.
"""
# category: line charts

import altair as alt

source = alt.sequence(start=0, stop=12.7, step=0.1, as_='x')

alt.Chart(source).mark_line().transform_calculate(
    sin='sin(datum.x)',
    cos='cos(datum.x)'
).transform_fold(
    ['sin', 'cos']
).encode(
    x='x:Q', 
    y='value:Q', 
    color='key:N'
)