# Simple Test-Time Refinement for Plot-to-Code Generation via Visual-Code Diagnostics

*Peiming Guo, Jinpeng Huang, Yangbin Sun, GaoXiong Cao, Ensheng Shi, Yuchi Ma, Yu Zhang, Meishan Zhang, Baotian Hu, Min zhang*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/149228) · [OpenReview](https://openreview.net/forum?id=rywd4Tm9jn) · [Open on the map](../papers.html#p149228)

Category: [LLM Agents, Evals & Benchmarks](../pcat/17.md) › [Code Generation](../pgroup/637.md) · Type: new method · Keywords: plot-to-code generation, visual-code diagnostics, test-time refinement, error localization, iterative correction

Areas: [Code & Coding Agents](../areas/codegen.md) › Code Generation and Optimization › Code Generation; [Evaluation & Benchmarks](../areas/evaluation.md) › Language Model and Agent Benchmarks › Code Generation Benchmarks

## Summary
The paper introduces a test-time refinement framework called Visual-Code Diagnostics that iteratively corrects plot-to-code generation errors using visual feedback, improving generation quality across multiple generators.

## Explained to a 5-year-old
People draw pictures that show how a program should work. A computer tries to write the code for those pictures, but sometimes it makes mistakes. Then a special system looks at the picture and the code to find the mistakes. It helps the computer fix the code little by little. After many tries, the code works better and matches the picture.

## Explained to a 5-year-old, longer
When you have a picture that shows what a program should do, you want a computer to write the code for it. The computer can try to write the code all at once, but it often makes mistakes. To help, we give the computer a way to look at the picture and the code together. It can see where the code does not match the picture. The computer then learns to spot four kinds of mistakes. It uses a small helper that tells it which part of the code is wrong. Then it changes just that part and tries again. This process repeats, fixing one mistake at a time. After many rounds, the code becomes more accurate. The picture and code become more similar. This makes the final program work better. It also helps when the picture is complicated. The whole idea is like a person drawing, checking, and erasing until everything looks right.

## For a technical reader
The system generates code from visual plots and then iteratively refines it by comparing rendered output with the code. It classifies errors into four categories and uses lightweight discriminators to locate mistakes, allowing targeted corrections without a full recompilation. This feedback loop improves accuracy across different generators and outperforms baseline test-time scaling methods.

## Problem
Generating code from visual plots is challenging because current methods produce errors that are hard to locate and fix, lacking an iterative refinement process that matches human debugging workflows.

## Method
The approach categorizes generation errors into four types and trains lightweight discriminators that use rendered visual outputs and code to recognize and localize errors, then iteratively refines the code based on this diagnostic feedback, without relying on traditional compiler or debugger verification.

## Results
The approach consistently improves generation quality across diverse generators and significantly outperforms strong test-time scaling baselines.

## Contributions
The paper is the first to investigate iterative test-time refinement for visual-to-code generation, introduces a scheme to categorize errors and train lightweight discriminators that use visual feedback to locate and correct mistakes, and demonstrates consistent gains over diverse generators and strong baselines.

## Research questions this paper is counted under

- [How can we automatically generate correct programs from ambiguous or incomplete specifications?](../q/876.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/149228)
