HAHS.
도구와 라이브러리로 돌아가기Back to Tools & Libraries

Vega-Altair

고수준 코드High-level code

Vega-Lite로 컴파일되는 선언적 Python 통계 시각화 라이브러리로, 현재 6버전입니다A declarative Python library for statistical charts that compiles to Vega-Lite, now at version 6

오픈소스Open source pythonweb Python

현재 버전Current version: 6.3.0, 정보 확인일 2026-10-24facts checked 2026-10-24

개요Overview

Vega-Altair(흔히 Altair)는 Python으로 Vega-Lite 명세를 만드는 선언적 시각화 라이브러리입니다. 데이터프레임의 열을 x, y, 색, 크기 같은 시각 채널에 대응시키는 방식으로 차트를 정의하고, 라이브러리가 이를 Vega-Lite JSON으로 바꿔 브라우저가 그립니다. 반복문으로 선을 하나씩 그리는 대신 "무엇을 어디에 대응시킬지"만 적습니다.

Vega-Altair, usually called Altair, is a declarative visualization library that builds Vega-Lite specifications from Python. You define a chart by mapping dataframe columns to visual channels such as x, y, colour and size, and the library turns that into Vega-Lite JSON that the browser draws. Instead of looping to draw each line, you state what maps to where.

차트 객체는 mark_*, encode, transform_*, add_params 같은 메서드를 이어 붙여 만듭니다. 선택(selection)과 파라미터로 브러시, 필터, 연결 뷰 같은 상호작용을 Python 코드만으로 선언하고, 결과는 Jupyter, Quarto, 정적 HTML, Streamlit 같은 환경에서 표시할 수 있습니다.

A chart object is built by chaining methods such as mark_*, encode, transform_* and add_params. Selections and params declare brushing, filtering and linked views in plain Python, and the result can be shown in Jupyter, Quarto, static HTML and tools such as Streamlit.

Matplotlib이 그리기 명령을 쌓는 방식이라면, Altair는 ggplot2에 가까운 그래픽 문법 방식입니다. R의 ggplot2를 써 본 사람에게 익숙하고, 출력이 데이터인 JSON이라서 AI가 코드를 생성하고 사람이 검토하기에 좋습니다. 2026년 현재 6.3.0이 최신이며 Python 3.11 이상이 필요합니다.

Where Matplotlib stacks drawing commands, Altair follows a grammar-of-graphics approach closer to ggplot2. It feels familiar to anyone who has used ggplot2 in R, and because its output is JSON data, it is a good fit for AI-generated code that a person reviews. As of 2026 the latest version is 6.3.0, which requires Python 3.11 or later.

2026년 현재What's new in 2026

  • 최신 버전은 6.3.0(2026-09-15)입니다. 6.0.0이 2025-11-12, 6.1.0이 2026-04-21에 나왔고 6.2.x가 2026년 6월에 나왔습니다. 라이선스는 BSD 3-Clause입니다.
  • The latest version is 6.3.0 (2026-09-15). Version 6.0.0 came out on 2025-11-12, 6.1.0 on 2026-04-21 and the 6.2.x releases in June 2026. The license is BSD 3-Clause.
  • 6.0.0은 Vega-Lite 6.1을 대상으로 하고, Python 3.14를 지원하며, 스레드 안전성을 높이고, 예제용 데이터를 불러오는 altair.datasets 모듈을 추가했습니다.
  • Version 6.0.0 targets Vega-Lite 6.1, supports Python 3.14, improves thread safety and adds an altair.datasets module for loading example datasets.
  • 6.3.0부터 Python 3.10 지원이 끝나 3.11 이상이 필요합니다. 또한 alt.datum[param] 사용이 지원됩니다.
  • Since 6.3.0, Python 3.10 is no longer supported and 3.11 or later is required. It also supports alt.datum[param].
  • 프로젝트 이름이 Vega-Altair로 정리되었습니다. PyPI에서도 패키지 이름은 그대로 altair이고 설명이 "Vega-Altair"입니다.
  • The project is now named Vega-Altair. On PyPI the package name is still altair and the summary reads "Vega-Altair".
  • 데이터프레임 처리에 Narwhals를 사용하므로 pandas뿐 아니라 Polars 등 여러 데이터프레임 라이브러리를 받습니다. pip install "altair[all]"은 pandas, NumPy, PyArrow, VegaFusion, vl-convert-python(정적 이미지 저장)을 함께 설치합니다.
  • Altair uses Narwhals for dataframe handling, so it accepts several dataframe libraries such as pandas and Polars. pip install "altair[all]" installs pandas, NumPy, PyArrow, VegaFusion and vl-convert-python (for saving static images) together.
  • 내장 AI 기능은 없습니다. LLM이 만든 Altair 코드는 예전 버전의 API를 섞어 쓰기도 하므로, 설치된 버전에서 실행해 확인하는 습관이 필요합니다.
  • There are no built-in AI features. LLM-written Altair code sometimes mixes in APIs from older versions, so run it on your installed version to check.

강점Strengths

  • 선언적이고 일관된 문법으로 코드가 짧고 읽기 쉽습니다.
  • A declarative, consistent grammar keeps code short and readable.
  • 선택과 파라미터로 브러시, 필터, 연결 하이라이트를 Python만으로 만듭니다.
  • Selections and params create brushing, filtering and linked highlighting in Python alone.
  • 겹치기(+), 나란히 놓기(|, &), 패싯으로 다중 뷰를 쉽게 조합합니다.
  • Layering (+), side-by-side composition (|, &) and facets combine multiple views easily.
  • 출력이 Vega-Lite JSON이라 웹, 노트북, Quarto, 정적 이미지로 재사용하기 좋습니다.
  • Because the output is Vega-Lite JSON, it is easy to reuse on the web, in notebooks, in Quarto and as static images.
  • 변환(집계, 윈도우, 필터 등)이 문법 안에 있어 간단한 집계는 차트 코드에서 바로 처리합니다.
  • Transforms (aggregate, window, filter and more) live in the grammar, so simple aggregation can happen in the chart code.
  • 하나의 개념 모델이라서 학습 곡선이 완만하고, AI가 생성한 코드를 검토하기 쉽습니다.
  • One conceptual model gives a gentle learning curve and makes AI-generated code easier to review.

한계Limitations

  • 차트의 범위가 Vega-Lite 문법에 묶여 있습니다. 샌키, 네트워크, 트리맵 같은 차트나 맞춤형 그래픽은 Matplotlib, D3 같은 다른 도구가 필요합니다.
  • The range of charts is bound by the Vega-Lite grammar. Sankey diagrams, networks, treemaps and fully custom graphics need other tools such as Matplotlib or D3.
  • 데이터가 차트 명세에 포함되어 브라우저에서 처리되므로, 행이 많은 데이터는 기본 설정에서 오류가 나거나 느려집니다. 먼저 집계하거나 VegaFusion을 사용해야 합니다.
  • Data is embedded in the chart specification and processed in the browser, so datasets with many rows raise an error or run slowly under the default settings. Aggregate first or use VegaFusion.
  • PNG나 SVG 같은 정적 파일 저장에는 vl-convert-python 같은 추가 패키지가 필요합니다.
  • Saving static files such as PNG or SVG needs an extra package such as vl-convert-python.
  • 세밀한 시각 디자인과 주석 배치는 Matplotlib만큼 자유롭지 않습니다.
  • Fine visual design and annotation placement are not as free as in Matplotlib.
  • 메이저 업데이트로 Python 최소 버전이 올라가고 있어 오래된 환경에서는 설치가 안 될 수 있습니다.
  • Python minimum versions keep rising with major updates, so installation can fail in old environments.

이런 용도에 최적Best For

Vega-Altair는 Python으로 분석하면서 상호작용이 있는 탐색 차트를 빠르게 만들고 싶을 때 잘 맞습니다. 변수 사이의 관계를 여러 뷰로 보는 노트북 분석, 수업에서 그래픽 문법을 가르치는 상황, 그리고 AI가 초안을 만들고 사람이 읽고 고치는 작업에 적합합니다.

Vega-Altair fits when you analyse in Python and want to make interactive exploratory charts quickly. It suits notebook analysis that looks at relationships between variables in several views, classes that teach the grammar of graphics, and work where an AI drafts a chart and a person reads and edits it.

출판용 정적 그림에서 모든 요소를 세밀하게 제어해야 한다면 Matplotlib이 낫고, 대시보드 앱이 목적이라면 Plotly Dash나 Streamlit과 함께 쓰는 방법을 고려합니다.

If a static publication figure needs fine control over every element, Matplotlib is better, and if the goal is a dashboard app, consider using it with Plotly Dash or Streamlit.

시작하기Getting Started

  1. Python 3.11 이상 환경에서 pip install "altair[all]"을 실행합니다.
  2. In a Python 3.11 or later environment, run pip install "altair[all]".
  3. 데이터프레임을 준비하고 alt.Chart(df)로 시작해 mark_*와 encode를 이어 붙입니다.
  4. Prepare a dataframe, start with alt.Chart(df) and chain mark_* and encode.
  5. 필드 뒤에 타입을 붙입니다(:Q 정량, :N 명목, :O 순서, :T 시간).
  6. Add a type after each field (:Q quantitative, :N nominal, :O ordinal, :T temporal).
  7. Jupyter에서는 차트 객체가 바로 표시되고, chart.save("name.html")로 파일을 만듭니다. PNG 저장에는 vl-convert-python이 필요합니다.
  8. In Jupyter the chart object displays directly, and chart.save("name.html") writes a file. Saving PNG needs vl-convert-python.
import altair as alt
import pandas as pd

# Sample data: revenue by region
df = pd.DataFrame({
    "region": ["Seoul", "Busan", "Daegu", "Gwangju"],
    "revenue": [120, 75, 52, 38],
})

chart = (
    alt.Chart(df)
    .mark_bar()
    .encode(
        x=alt.X("region:N", sort="-y", title="Region"),
        y=alt.Y("revenue:Q", title="Revenue (million KRW)"),
        tooltip=["region", "revenue"],
    )
    .properties(width=400, height=250, title="Revenue by region")
)

chart.save("revenue.html")
chart  # displays inline in Jupyter

지원 차트 유형Supported Chart Types

Vega-Altair는 Vega-Lite가 지원하는 차트를 그대로 만듭니다. 막대 차트, 누적 막대 차트, 선 그래프, 영역 그래프, 산점도, 버블 차트, 히스토그램, 히트맵, 상자 그림, 오차 막대, 파이와 도넛 차트(mark_arc), 지도(mark_geoshape)가 가능하고, 패싯과 겹치기, 연결로 작은 다중 차트와 대시보드형 화면을 구성합니다. 샌키, 네트워크, 트리맵은 지원하지 않습니다.

Vega-Altair makes the charts that Vega-Lite supports. That includes bar charts, stacked bar charts, line graphs, area graphs, scatterplots, bubble charts, histograms, heatmaps, box plots, error bars, pie and donut charts (mark_arc) and maps (mark_geoshape), and facets, layers and concatenation build small multiples and dashboard-style screens. Sankey diagrams, networks and treemaps are not supported.