Download README.md from figmirror/PlotTwin-Bench: direct link, hf CLI and curl.
- Browser
- Download file 7.82 kB
-
https://huggingface.co/datasets/figmirror/PlotTwin-Bench/resolve/main/README.md
- Command line
-
hf download hf://datasets/figmirror/PlotTwin-Bench/README.md
-
curl -L -o README.md https://huggingface.co/datasets/figmirror/PlotTwin-Bench/resolve/main/README.md
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.
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.
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.
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.
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:
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 | 151 | non-commercial notice |
| Chart2Code | 151 | level 1 follows ChartMimic (Apache-2.0); levels 2–3 state no licence |
| Chart2NCode | 31 | CC BY-NC 4.0 |
| ChartMimic | 15 | Apache-2.0 |
| 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
@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}
}