Chart Reading
Category: perception
Skill Level: intermediate
Stability: stable
Added: 2025-03
Last Updated: 2026-04
Description
Interpret charts, graphs, and data visualizations from images to extract numerical values, trends, comparisons, and patterns. Supports bar charts, line charts, pie charts, scatter plots, histograms, heatmaps, and dashboards. The model reads axis labels, legends, titles, and data points — returning structured JSON, markdown tables, or natural-language summaries.
Inputs
| Input |
Type |
Required |
Description |
image |
bytes / url |
✅ |
Chart image (PNG, JPEG, WebP) or public URL |
output_format |
string |
❌ |
json (default), markdown, or prose |
context |
string |
❌ |
Domain hint, e.g. "financial quarterly report" |
Outputs
| Output |
Type |
Description |
chart_type |
string |
Detected chart type |
series |
list |
Data series with labels and values |
key_insight |
string |
One-sentence summary of the main trend |
Example
import anthropic
import base64
from pathlib import Path
client = anthropic.Anthropic()
def read_chart(image_path: str) -> str:
"""Extract structured data from a chart image."""
image_data = base64.standard_b64encode(
Path(image_path).read_bytes()
).decode("utf-8")
response = client.messages.create(
model="claude-opus-4-5",
max_tokens=1024,
messages=[{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": image_data,
},
},
{
"type": "text",
"text": (
"Analyze this chart and return a JSON object with:\n"
"- chart_type: type of chart\n"
"- title: chart title if present\n"
"- x_axis: {label, values}\n"
"- y_axis: {label, unit}\n"
"- series: [{name, values}]\n"
"- key_insight: one-sentence trend summary\n"
"Return ONLY valid JSON."
)
}
],
}]
)
return response.content[0].text
result = read_chart("quarterly_revenue.png")
print(result)
# URL-hosted chart
response = client.messages.create(
model="claude-opus-4-5",
max_tokens=1024,
messages=[{
"role": "user",
"content": [
{"type": "image", "source": {"type": "url", "url": "https://example.com/chart.png"}},
{"type": "text", "text": "Extract all data series as JSON."}
]
}]
)
Frameworks & Models
| Framework / Model |
Implementation |
Since |
| Claude claude-opus-4-5 |
Native vision via image content block |
2024-06 |
| GPT-4o |
Vision via image_url content block |
2024-05 |
| LangChain |
ChatAnthropic + base64 image message |
v0.2 |
Notes
- For URL-hosted charts use
{"type": "url", "url": chart_url} instead of base64
- Pass
"Return ONLY valid JSON" to suppress prose wrapping
- Low-resolution or heavily compressed images reduce accuracy; request 1x–2x renders
- For dashboards with multiple charts, crop each chart individually before passing
Related Skills
- Image Understanding — foundation vision skill
- OCR — when axis labels are the primary target
- Document Parsing — for charts embedded in reports
- Structured Data Reading — post-extraction processing
Changelog
| Date |
Change |
2026-04 |
Expanded from stub: full description, inputs/outputs table, two code examples, notes |
2025-03 |
Initial stub entry |
Failure Modes
| Failure Mode |
Cause |
Mitigation |
| Untrusted input causes incorrect extraction |
Malformed, adversarial, or incomplete source data |
Validate structure, bound input size, preserve source provenance, and reject ambiguous results when required |
| Model or parser overstates certainty |
Heuristic extraction is treated as authoritative |
Return source spans or structured evidence and distinguish extraction from verification |
| Context or resource exhaustion |
Large files, histories, responses, or media are processed without limits |
Apply size, time, row, page, or token limits and process incrementally |
Evidence
The skill's implementation guidance is grounded in the following primary references:
Evidence status: implementation guidance verified against the cited documentation; no benchmark claim is made unless a reproducible benchmark is included in this file.
1---2name: chart-reading3description: Extract chart structure and reported values from visualizations, then return traceable series, axes, units, and trends. Use it when numerical or categorical information is encoded primarily in a chart image.4metadata:5 source: https://skillmd.com/skills/samotech/chart-reading6 upstream: skills/01-perception/chart-reading.md7 category: 01-perception8 version: "v2"9---10111213# Chart Reading1415**Category:** `perception`16**Skill Level:** `intermediate`17**Stability:** `stable`18**Added:** 2025-0319**Last Updated:** 2026-042021---2223## Description2425Interpret charts, graphs, and data visualizations from images to extract numerical values, trends, comparisons, and patterns. Supports bar charts, line charts, pie charts, scatter plots, histograms, heatmaps, and dashboards. The model reads axis labels, legends, titles, and data points — returning structured JSON, markdown tables, or natural-language summaries.2627---2829## Inputs3031| Input | Type | Required | Description |32|---|---|---|---|33| `image` | `bytes` / `url` | ✅ | Chart image (PNG, JPEG, WebP) or public URL |34| `output_format` | `string` | ❌ | `json` (default), `markdown`, or `prose` |35| `context` | `string` | ❌ | Domain hint, e.g. `"financial quarterly report"` |3637---3839## Outputs4041| Output | Type | Description |42|---|---|---|43| `chart_type` | `string` | Detected chart type |44| `series` | `list` | Data series with labels and values |45| `key_insight` | `string` | One-sentence summary of the main trend |4647---4849## Example5051```python52import anthropic53import base6454from pathlib import Path5556client = anthropic.Anthropic()5758def read_chart(image_path: str) -> str:59 """Extract structured data from a chart image."""60 image_data = base64.standard_b64encode(61 Path(image_path).read_bytes()62 ).decode("utf-8")6364 response = client.messages.create(65 model="claude-opus-4-5",66 max_tokens=1024,67 messages=[{68 "role": "user",69 "content": [70 {71 "type": "image",72 "source": {73 "type": "base64",74 "media_type": "image/png",75 "data": image_data,76 },77 },78 {79 "type": "text",80 "text": (81 "Analyze this chart and return a JSON object with:\n"82 "- chart_type: type of chart\n"83 "- title: chart title if present\n"84 "- x_axis: {label, values}\n"85 "- y_axis: {label, unit}\n"86 "- series: [{name, values}]\n"87 "- key_insight: one-sentence trend summary\n"88 "Return ONLY valid JSON."89 )90 }91 ],92 }]93 )94 return response.content[0].text9596result = read_chart("quarterly_revenue.png")97print(result)98```99100```python101# URL-hosted chart102response = client.messages.create(103 model="claude-opus-4-5",104 max_tokens=1024,105 messages=[{106 "role": "user",107 "content": [108 {"type": "image", "source": {"type": "url", "url": "https://example.com/chart.png"}},109 {"type": "text", "text": "Extract all data series as JSON."}110 ]111 }]112)113```114115---116117## Frameworks & Models118119| Framework / Model | Implementation | Since |120|---|---|---|121| Claude claude-opus-4-5 | Native vision via `image` content block | 2024-06 |122| GPT-4o | Vision via `image_url` content block | 2024-05 |123| LangChain | `ChatAnthropic` + base64 image message | v0.2 |124125---126127## Notes128129- For URL-hosted charts use `{"type": "url", "url": chart_url}` instead of base64130- Pass `"Return ONLY valid JSON"` to suppress prose wrapping131- Low-resolution or heavily compressed images reduce accuracy; request 1x–2x renders132- For dashboards with multiple charts, crop each chart individually before passing133134---135136## Related Skills137138- [Image Understanding](image-understanding.md) — foundation vision skill139- [OCR](ocr.md) — when axis labels are the primary target140- [Document Parsing](document-parsing.md) — for charts embedded in reports141- [Structured Data Reading](structured-data-reading.md) — post-extraction processing142143---144145## Changelog146147| Date | Change |148|---|---|149| `2026-04` | Expanded from stub: full description, inputs/outputs table, two code examples, notes |150| `2025-03` | Initial stub entry |151152153## Failure Modes154155| Failure Mode | Cause | Mitigation |156|---|---|---|157| Untrusted input causes incorrect extraction | Malformed, adversarial, or incomplete source data | Validate structure, bound input size, preserve source provenance, and reject ambiguous results when required |158| Model or parser overstates certainty | Heuristic extraction is treated as authoritative | Return source spans or structured evidence and distinguish extraction from verification |159| Context or resource exhaustion | Large files, histories, responses, or media are processed without limits | Apply size, time, row, page, or token limits and process incrementally |160161162## Evidence163164The skill's implementation guidance is grounded in the following primary references:165- Anthropic vision documentation: https://docs.anthropic.com/en/docs/build-with-claude/vision166- Agent Skills specification for packaging reusable visual-analysis procedures: https://agentskills.io/specification167168Evidence status: implementation guidance verified against the cited documentation; no benchmark claim is made unless a reproducible benchmark is included in this file.