File size: 7,820 Bytes
dcf1edd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5905ce0
dcf1edd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52d0b98
dcf1edd
 
 
 
52d0b98
dcf1edd
 
52d0b98
 
 
dcf1edd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0610fc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dcf1edd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
---
license: cc-by-nc-4.0
pretty_name: PlotTwin-Bench
language:
- en
task_categories:
- image-to-text
- text-to-image
tags:
- figure-style-transfer
- chart-to-code
- scientific-figures
- matplotlib
size_categories:
- n<1K
configs:
- config_name: bench
  default: true
  data_files:
  - split: test
    path: data/bench/*.parquet
- config_name: full
  data_files:
  - split: test
    path: data/full/*.parquet
---

# PlotTwin-Bench

PlotTwin-Bench is a benchmark for **figure style transfer**: given a reference
figure and a new dataset, produce a plotting script that draws the new data in
the reference's visual style. Every reference is a publication-style matplotlib
figure shipped with the script that renders it.

- Paper: [FigMirror: Ground It, Code It, Plot It](https://arxiv.org/abs/2608.28814)
- Code: [github.com/VILA-Lab/FigMirror](https://github.com/VILA-Lab/FigMirror)

## Configs

| config | rows | style-transfer tasks | contents |
|---|---:|---:|---|
| `bench` (default) | 150 | 150 | the evaluation set: all 50 hand-curated references and 100 augmented references sampled at random |
| `full` | 399 | 150 | every reference: 50 hand-curated and 349 augmented; the 150 `bench` rows carry target data |

`bench` is a subset of `full`, and each `bench` row appears in `full` unchanged.

```python
from datasets import load_dataset

bench = load_dataset("figmirror/PlotTwin-Bench", split="test")          # 150 tasks
full = load_dataset("figmirror/PlotTwin-Bench", "full", split="test")   # 399 references
tasks = full.filter(lambda x: x, input_columns="in_bench")              # same 150 tasks
```

## Two sources

**Hand-curated (50).** Complex figures selected from papers at top venues and
journals, each replotted by hand in matplotlib to form an aligned figure–code
pair. Every hand-curated row cites the figure it was replotted from
(`source_url`, `source_title`, `source_bibkey`; BibTeX in `sources.bib`). The
reference image is our own rendering, not the published figure.

**Augmented (349).** Plotting code from existing chart-to-code datasets,
rewritten by an LLM pipeline into more complex and visually polished figures,
then filtered for both properties. Each row records its seed (`seed_dataset`,
`seed_url`, `seed_id`).

## Task

A task pairs `reference_image` with `target_data`, a CSV describing a new study
in a different scientific domain. The target data keeps the reference's chart
families and panel structure and changes one to three aspects of the data, such
as series count, category cardinality, panel allocation or scale type. A method
returns a self-contained plotting script that draws `target_data` in the style
of `reference_image`.

## Fields

| field | type | description |
|---|---|---|
| `reference_image` | image | the reference figure, rendered by `reference_code` |
| `id` | string | sample id |
| `source` | string | `hand-curated` or `augmented` |
| `chart_type`, `chart_type_name` | string | one of 12 chart types, `T1` Bar … `T12` Composite |
| `panel_mode` | string | `single` or `multi` |
| `in_bench` | bool | the row belongs to the `bench` evaluation set |
| `source_url`, `source_title`, `source_bibkey` | string | publication a hand-curated reference was replotted from |
| `seed_dataset`, `seed_url`, `seed_id` | string | upstream seed of an augmented reference |
| `target_data` | string | CSV to plot in the reference style; set on the 150 task rows |
| `reference_code` | string | matplotlib script that renders `reference_image` |
| `reference_data` | list | data files the script reads (`filename`, `content`) |

## Rendering a reference

`reference_code` reads its data files from its own directory and saves one PNG.

```python
from pathlib import Path
import subprocess, sys

def materialize(row, workdir):
    workdir = Path(workdir) / row["id"]
    workdir.mkdir(parents=True, exist_ok=True)
    (workdir / "code.py").write_text(row["reference_code"])
    for f in row["reference_data"]:
        (workdir / f["filename"]).write_bytes(f["content"])
    if row["target_data"]:
        (workdir / "target_data.csv").write_text(row["target_data"])
    return workdir

sample = materialize(bench[0], "plottwin")
subprocess.run([sys.executable, "code.py"], cwd=sample, check=True)
```

The released images were rendered with Python 3.13, matplotlib 3.10.9 and
numpy 2.4.4 (Agg backend). Other font sets or library versions can change text
rasterisation slightly.

## Scoring

The `scorer/` folder holds the PlotTwin-Bench scorer (`deviation-defect-v1`).

- **S_code** parses the reference and candidate scripts and compares nine style
  attributes: palette, background, figure aspect, line width, grid, hidden
  spines, tick direction, serif font and legend frame. An attribute counts only
  when the reference departs from the matplotlib default.
- **S_vision** shows a vision model the reference and the candidate image and
  asks for every reference style choice the candidate misses. Each miss deducts
  5, 10 or 25 points (minor, major, critical) from 100.
- **S** averages each channel over a split and blends them:
  `S = 0.65 · S_vision + 0.35 · S_code`.

A prediction is one `<id>.py` per task. The script reads the target data from
`data.csv` in its working directory and saves one PNG; the scorer renders it.
A `<id>.png` next to the script is used as the candidate image instead.

```bash
hf download figmirror/PlotTwin-Bench --repo-type dataset --include "scorer/*" --local-dir plottwin
cd plottwin/scorer
export OPENAI_API_KEY=...        # set OPENAI_BASE_URL for any OpenAI-compatible endpoint
uv run plottwin-score --pred-dir /path/to/predictions --out-dir scores
```

The vision model defaults to `gpt-5.5`; set `--model` and `--reasoning-effort`
to change it. Per-sample results go to `scores/per_sample/<id>.json` and are
reused when a run restarts; `scores/summary.json` reports S, S_code and
S_vision for the hand-curated and augmented splits. `examples/quickstart.py`
scores a default-style baseline on three tasks end to end:

```bash
uv run python examples/quickstart.py
```

## Chart types

| type | hand-curated | augmented (`full`) | `bench` total |
|---|---:|---:|---:|
| T1 Bar | 0 | 140 | 18 |
| T2 Line | 5 | 70 | 20 |
| T3 Scatter | 5 | 25 | 16 |
| T4 Distribution | 9 | 10 | 17 |
| T5 Box/Violin | 5 | 27 | 16 |
| T6 Heatmap | 4 | 19 | 14 |
| T7 Field 2D | 5 | 19 | 15 |
| T8 3D | 4 | 5 | 7 |
| T9 Network/Tree | 2 | 3 | 2 |
| T10 Polar/Radial | 1 | 29 | 13 |
| T11 Std-band | 7 | 2 | 9 |
| T12 Composite | 3 | 0 | 3 |

## License and attribution

PlotTwin-Bench is released under CC BY-NC 4.0. Augmented references derive from
the plotting code of these datasets; follow their terms as well:

| seed dataset | rows in `full` | upstream terms |
|---|---:|---|
| [ChartNet](https://huggingface.co/datasets/ibm-granite/ChartNet) | 151 | non-commercial notice |
| [Chart2Code](https://huggingface.co/datasets/CSU-JPG/Chart2Code) | 151 | level 1 follows ChartMimic (Apache-2.0); levels 2–3 state no licence |
| [Chart2NCode](https://huggingface.co/datasets/Zhihan/Chart2NCode) | 31 | CC BY-NC 4.0 |
| [ChartMimic](https://huggingface.co/datasets/ChartMimic/ChartMimic) | 15 | Apache-2.0 |
| [ChartGen-200K](https://huggingface.co/datasets/SD122025/ChartGen-200K) | 1 | CC BY 4.0 |

Hand-curated references are our own matplotlib replots; please also cite the
original publications listed in `sources.bib` when you discuss individual
figures.

## Citation

```bibtex
@misc{zhao2026figmirrorgrounditcode,
  title         = {FigMirror: Ground It, Code It, Plot It},
  author        = {Xiaohan Zhao and Jiacheng Liu and Yaxin Luo and Zhiqiang Shen},
  year          = {2026},
  eprint        = {2608.28814},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CV},
  url           = {https://arxiv.org/abs/2608.28814}
}
```