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

Matplotlib

저수준 코드Low-level code

Python 시각화의 기반이 되는 라이브러리로, 현재 3.11 세대이며 그림의 모든 요소를 세밀하게 제어할 수 있습니다The foundational Python plotting library, now at 3.11, with full control over every element of a figure

오픈소스Open source pythonwindowsmaclinux Python

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

개요Overview

Matplotlib은 Python에서 가장 오래되고 널리 쓰이는 시각화 라이브러리입니다. 존 헌터(John D. Hunter)가 만들었고 지금은 NumFOCUS가 재정을 후원하는 커뮤니티 오픈소스 프로젝트입니다. Figure, Axes, Artist라는 객체를 직접 다루면서 선, 점, 글자, 눈금 같은 모든 요소의 위치와 모양을 지정할 수 있어, 저수준이지만 거의 모든 2D 그래픽을 만들 수 있습니다.

Matplotlib is the oldest and most widely used visualization library in Python. It was created by John D. Hunter and is now a community open-source project fiscally sponsored by NumFOCUS. You work directly with Figure, Axes and Artist objects and set the position and look of every line, marker, text and tick, so it is low level but can produce almost any 2D graphic.

seaborn과 pandas의 .plot() 같은 많은 고수준 도구가 Matplotlib 위에서 동작하고, 노트북에서 보는 그림의 상당수가 Matplotlib 출력입니다. Python in Excel도 Matplotlib을 사용할 수 있습니다. 그래서 다른 도구를 선호하더라도 Matplotlib 코드를 읽고 고치는 능력은 필요합니다.

Many higher-level tools, such as seaborn and pandas .plot(), run on top of Matplotlib, and a large share of the figures in notebooks are Matplotlib output. Python in Excel can use Matplotlib too. So even if you prefer another tool, you will need to read and edit Matplotlib code.

2026년 현재 최신은 3.11.2(2026-09-11)이며 Python 3.11 이상이 필요합니다. AI 도구가 만들어 주는 Python 그래프 코드의 대부분도 Matplotlib입니다. 그래서 AI의 코드가 무엇을 그리는지 이해하고 점검하는 기초 도구로 배울 가치가 큽니다.

As of 2026 the latest release is 3.11.2 (2026-09-11), and it requires Python 3.11 or later. Most of the Python plotting code that AI tools write is Matplotlib as well, so it is worth learning as the base tool for understanding and checking what that code draws.

2026년 현재What's new in 2026

  • 최신 버전은 3.11.2(2026-09-11)입니다. 3.11.0은 2026-06-11에 나왔고, 3.10 계열의 마지막 패치는 3.10.9(2026-04-23)입니다.
  • The latest version is 3.11.2 (2026-09-11). Version 3.11.0 came out on 2026-06-11, and the last 3.10 patch is 3.10.9 (2026-04-23).
  • 3.11은 Python 3.11 이상을 요구하므로 오래된 Python 환경에서는 3.10 계열에 머물게 됩니다.
  • Version 3.11 requires Python 3.11 or later, so older Python environments stay on the 3.10 series.
  • 내장 AI 기능은 없습니다. Matplotlib은 LLM이 가장 많이 생성하는 Python 그림 코드이므로, 색, 축 범위, 집계 방식을 코드에서 직접 읽어 확인하는 연습이 중요합니다.
  • There are no built-in AI features. Matplotlib is the plotting code LLMs generate most often in Python, so practise reading the colours, axis limits and aggregation directly in the code.

강점Strengths

  • 거의 모든 요소를 제어할 수 있어 출판 품질의 맞춤 그림을 만듭니다.
  • Control over nearly every element yields custom, publication-quality figures.
  • PNG, SVG, PDF 같은 형식으로 해상도와 크기를 정해 저장합니다.
  • It saves to formats such as PNG, SVG and PDF at a chosen resolution and size.
  • NumPy, pandas와 자연스럽게 연결되고, seaborn 같은 다른 라이브러리의 기반입니다.
  • It connects naturally with NumPy and pandas and is the base of libraries such as seaborn.
  • 선, 막대, 산점, 히스토그램부터 등고선, 3D, 극좌표, 애니메이션까지 폭넓은 범위를 지원합니다.
  • The range is wide: lines, bars, scatter and histograms through contours, 3D, polar plots and animation.
  • 문서, 예제 갤러리, 커뮤니티 자료가 매우 풍부합니다.
  • Documentation, the example gallery and community resources are abundant.
  • 오픈소스이고 NumFOCUS의 후원을 받는 프로젝트입니다.
  • It is open source and a NumFOCUS fiscally sponsored project.

한계Limitations

  • 같은 차트를 만들 때 ggplot2나 Altair보다 코드가 길고 장황합니다.
  • Making the same chart takes longer, more verbose code than ggplot2 or Altair.
  • 기본 스타일은 현대적인 디자인 기준에서 투박해 보일 수 있어 스타일 설정이 필요합니다.
  • The default style can look plain by modern design standards, so you need to adjust styles.
  • 상호작용과 웹 공유는 기본 기능이 아닙니다. 노트북 백엔드나 다른 도구를 추가해야 합니다.
  • Interaction and web sharing are not core features. You need a notebook backend or another tool.
  • pyplot 방식과 객체지향 방식이 섞여 있어 예전 예제를 따라 하다 혼란을 겪기 쉽습니다.
  • The pyplot style and the object-oriented style are mixed, which confuses learners following older examples.
  • 샌키, 트리맵, 네트워크 같은 차트는 별도 라이브러리가 필요합니다.
  • Charts such as Sankey diagrams, treemaps and networks need separate libraries.

이런 용도에 최적Best For

Matplotlib은 논문과 보고서에 들어가는 정적 그림, 특히 크기와 글꼴, 주석 위치까지 정확히 맞춰야 하는 그림에 잘 맞습니다. 과학 계산, 신호 처리, 시뮬레이션처럼 NumPy 결과를 바로 그려 보는 작업과, 다른 라이브러리가 만든 그림을 마지막에 다듬는 작업에도 쓰입니다.

Matplotlib fits static figures for papers and reports, especially figures where size, font and annotation placement must be exact. It is also used to plot NumPy results directly in scientific computing, signal processing and simulation, and to polish a figure that another library produced.

빠른 탐색이나 상호작용이 있는 웹 차트가 목적이라면 Altair나 Plotly가 더 편합니다. 처음에는 AI가 만든 Matplotlib 코드를 읽는 수준부터 시작해도 좋습니다.

For quick exploration or interactive web charts, Altair or Plotly is easier. It is fine to start at the level of reading Matplotlib code that an AI wrote.

시작하기Getting Started

  1. Python 3.11 이상 환경에서 python -m pip install matplotlib을 실행합니다.
  2. In a Python 3.11 or later environment, run python -m pip install matplotlib.
  3. fig, ax = plt.subplots()로 Figure와 Axes를 만드는 객체지향 방식으로 시작합니다.
  4. Start with the object-oriented style: create a Figure and Axes with fig, ax = plt.subplots().
  5. ax.bar, ax.plot, ax.scatter 같은 메서드로 그리고, 라벨과 범위를 ax에서 설정합니다.
  6. Draw with methods such as ax.bar, ax.plot and ax.scatter, and set labels and limits on ax.
  7. fig.savefig()로 크기와 해상도를 지정해 저장합니다. 막대 차트는 y축을 0에서 시작하는지 확인합니다.
  8. Save with fig.savefig() at a chosen size and resolution. For bar charts, check that the y axis starts at 0.
import matplotlib.pyplot as plt

# Sample data: revenue by region
regions = ["Seoul", "Busan", "Daegu", "Gwangju"]
revenue = [120, 75, 52, 38]

fig, ax = plt.subplots(figsize=(6, 4), constrained_layout=True)
bars = ax.bar(regions, revenue, color="#4C78A8")
ax.bar_label(bars)
ax.set_ylim(bottom=0)
ax.set_xlabel("Region")
ax.set_ylabel("Revenue (million KRW)")
ax.set_title("Revenue by region")
ax.spines[["top", "right"]].set_visible(False)

fig.savefig("revenue.png", dpi=200)
plt.show()

지원 차트 유형Supported Chart Types

Matplotlib은 선 그래프, 막대 차트와 가로 막대 차트, 누적 막대 차트, 산점도와 버블 차트, 히스토그램, 2D 히스토그램과 hexbin, 상자 그림, 바이올린 플롯, 파이 차트, 오차 막대, 영역 그래프(fill_between, stackplot), 히트맵(imshow, pcolormesh), 등고선, 극좌표 차트, 3D 표면과 산점도, 벡터장(quiver), 애니메이션을 지원합니다. subplots로 작은 다중 차트를 만들 수 있고, 지도는 cartopy 같은 확장과 함께 씁니다. 상호작용이 있는 웹 차트와 샌키, 트리맵, 네트워크는 기본 범위 밖입니다.

Matplotlib supports line graphs, bar and horizontal bar charts, stacked bar charts, scatterplots and bubble charts, histograms, 2D histograms and hexbin, box plots, violin plots, pie charts, error bars, area graphs (fill_between, stackplot), heatmaps (imshow, pcolormesh), contours, polar charts, 3D surface and scatter plots, vector fields (quiver) and animation. subplots builds small multiples, and maps are made together with extensions such as cartopy. Interactive web charts, Sankey diagrams, treemaps and networks are outside its core scope.