Beispiel #1
0
라인 그래프 계단형
"""
source = data.stocks()

#공통 특성
base = alt.Chart(data=source).encode(color='symbol', strokeDash='symbol')

#라인
line = base.mark_line(interpolate='step-after').encode(x=alt.X('date',
                                                               title='Date'),
                                                       y=alt.Y('price',
                                                               title='Price'))
chart = alt.layer(line).properties(width=550)
chart.save('Simple Line Chart6.html')
"""
라인 그래프 - Custom Path
"""
source = data.driving()

#공통 특성
base = alt.Chart()

#라인
line = base.mark_line(point=True).encode(
    x=alt.X('miles', scale=alt.Scale(zero=False)),
    y=alt.Y('gas', scale=alt.Scale(zero=False)),
    order='year'  #선 그리는 순서
)

chart = alt.layer(line, data=source)
chart.save('Simple Line Chart7.html')
"""
Connected Scatterplot (Lines with Custom Paths)
-----------------------------------------------

This example show how the order encoding can be used to draw a custom path. The dataset tracks miles driven per capita along with gas prices annually from 1956 to 2010.
It is based on Hannah Fairfield's article 'Driving Shifts Into Reverse'. See https://archive.nytimes.com/www.nytimes.com/imagepages/2010/05/02/business/02metrics.html for the original.
"""
# category: scatter plots
import altair as alt
from vega_datasets import data

source = data.driving()

alt.Chart(source).mark_line(point=True).encode(
    alt.X('miles', scale=alt.Scale(zero=False)),
    alt.Y('gas', scale=alt.Scale(zero=False)),
    order='year'
)
Beispiel #3
0
"""
Connected Scatterplot (Lines with Custom Paths)
-----------------------------------------------

This example show how the order encoding can be used to draw a custom path. The dataset tracks miles driven per capita along with gas prices annually from 1956 to 2010. 
It is based on Hannah Fairfield's article 'Driving Shifts Into Reverse'. See https://archive.nytimes.com/www.nytimes.com/imagepages/2010/05/02/business/02metrics.html for the original. 
"""
# category: scatter plots
import altair as alt
from vega_datasets import data

driving = data.driving()

alt.Chart(driving).mark_line(point=True).encode(
    alt.X('miles', scale=alt.Scale(zero=False)),
    alt.Y('gas', scale=alt.Scale(zero=False)),
    order='year')