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

# 从终端生成 matplotlib 图表

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

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

<Note>
  **请始终在命令前加 `arka`。** 下文所有示例均为 `arka …` 或 `arka "自然语言"`。Fish 中也可使用 `chart …` 等快捷方式，但文档与复制粘贴示例统一使用 `arka`。
</Note>

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

## 图表类型

| 类型 | CLI | 自然语言（通过 `arka`） |
| - | - | - |
| line | `arka chart line AAPL TSLA --range 1y` | `arka "compare Apple and Tesla stock last year"` |
| bar | `arka chart bar --data "A:1,B:2"` | `arka "phone sales Apple 230 Samsung 210"` |
| pie | `arka chart pie --data "A:40,B:30"` | `arka "pie chart traffic organic 400 direct 300"` |
| scatter | `arka chart scatter --data "100:200,120:190"` | `arka "scatter ad spend vs revenue 100 200 120 190"` |
| histogram | `arka chart histogram --data "12,15,18,22"` | `arka "histogram response times 12 15 18 22"` |
| pareto | `arka chart pareto --data "A:45,B:28"` | `arka "pareto defects Scratches 45 Dents 28"` |
| prediction | `arka chart predict AAPL --days 30` | `arka "predict AAPL stock price chart next 30 days"` |
| model traits | `arka chart models --type scatter` | `arka "chart AI model characteristics scatter"` |
| table image | `arka chart table sales.csv --title "Q1"` | `arka "render metrics.csv as table png"` |
| from file | `arka chart from metrics.csv --type line` | `arka "chart ~/data/metrics.csv as line"` |

## 自然语言示例

将整句作为引号参数传给 `arka`：

```bash theme={null}
arka "make a chart of training loss"
arka "chart training loss 1:0.8 2:0.5 3:0.3"
arka "visualize metrics.csv"
```

## 直接使用 CLI

```bash theme={null}
arka chart line AAPL TSLA --range 1y
arka chart predict RELIANCE.NS --days 30 --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"
arka chart table sales.csv --title "Q1 销售"
```

## 表格 PNG

将 CSV/TSV/JSON 渲染为带表头的 PNG 表格：

```bash theme={null}
arka chart table sales.csv
arka "render metrics.csv as table png"
```

## 未来预测

```bash theme={null}
arka predict future "rainfall in Mumbai next 2 weeks" --chart
arka predict future "from kaggle heptapod/titanic next 30 days" --chart
arka chart models --type scatter
```

## 图表默认值

在 `~/.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)
- [Kaggle 数据集](/cn/guides/kaggle.md)
- [Arka 简介](/cn/index.md)
- [书签管理器](/cn/guides/bookmarks.md)
- [剪贴板历史](/cn/guides/clipboard-history.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.