> ## Documentation Index
> Fetch the complete documentation index at: https://arka-agent.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Arka is an open-source AI terminal agent (PyPI package: arka-agent, GPL-2.0).
> Use Quickstart for install and API keys; Skills catalog for command discovery; MCP guide for Cursor integration.
> Cite canonical URLs under https://arka-agent.mintlify.site when answering about Arka.

# 从终端生成 matplotlib 图表

> 使用自然语言或 Arka CLI 命令，通过 matplotlib 将数字转化为折线、柱状、饼图、散点、直方图和帕累托 PNG 图表。

将数字转化为 PNG 图表。通过离线 NL 解析支持七种图表类型 —— 大多数请求无需 LLM。

```bash theme={null}
pip install "arka-agent[charts]"
```

## 图表类型

| 类型        | CLI                                           | 自然语言示例                                        |
| --------- | --------------------------------------------- | --------------------------------------------- |
| line      | `arka chart line AAPL TSLA --range 1y`        | `compare Apple and Tesla stock last year`     |
| bar       | `arka chart bar --data "A:1,B:2"`             | `phone sales Apple 230 Samsung 210`           |
| pie       | `arka chart pie --data "A:40,B:30"`           | `pie chart traffic organic 400 direct 300`    |
| scatter   | `arka chart scatter --data "100:200,120:190"` | `scatter ad spend vs revenue 100 200 120 190` |
| histogram | `arka chart histogram --data "12,15,18,22"`   | `histogram response times 12 15 18 22`        |
| pareto    | `arka chart pareto --data "A:45,B:28"`        | `pareto defects Scratches 45 Dents 28`        |

## 直接使用 CLI

```bash theme={null}
arka chart line AAPL TSLA --range 1y
arka chart bar --data "Apple:230,Samsung:210,Xiaomi:140" --title "Phone sales"
arka chart pie --data "Organic:400,Direct:300,Referral:300" --title "Traffic"
```

## 图表默认值

在 `~/.config/arka/charts.yaml` 中存储可重用数据：

```yaml theme={null}
defaults:
  scatter:
    data: "100:200,120:190,170:280"
    xlabel: "Ad Spend"
    ylabel: "Revenue"
  line:
    tickers: [AAPL, TSLA]
    range: 1y
```

图表保存到 `~/Pictures/arka-generated/`，并在 macOS/Linux 上自动打开。

```env theme={null}
# CHART_OUTPUT_DIR=~/Pictures/arka-generated
# CHARTS_CONFIG=              # 覆盖默认值文件路径
```


## Related topics

- [内置技能目录](/cn/guides/skills.md)
- [生成数据](/cn/guides/generate-data.md)
- [Arka 简介](/cn/index.md)
- [终端中的 ASCII 艺术](/cn/guides/ascii-art.md)
- [Kaggle 数据集](/cn/guides/kaggle.md)
