NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ChartCoder: Advancing Multimodal Large Language Model for Chart-to-Code Generation

Xuanle Zhao, Xianzhen Luo, Qi Shi, Chi Chen, Shuo Wang, Zhiyuan Liu, Maosong Sun

Introduction

While Multimodal Large Language Models (MLLMs) have become proficient at describing charts or answering questions about them, they often struggle with chart-to-code generation—the task of reproducing a plot's exact source code from an image. Current models face three primary hurdles: information loss during text conversion, low executability due to a lack of "native" coding proficiency, and a scarcity of high-quality training data.

Methodology

ChartCoder addresses these challenges by utilizing a specialized code-centric backbone, DeepSeek Coder 6.7B, rather than a general-purpose language model. The training process is divided into two distinct phases: Chart-to-Text Alignment for perception and Chart-to-Code Instruction Tuning for generation mastery.

Overview of the ChartCoder data generation pipelines and model training stages.

A core innovation is the Snippet-of-Thought (SoT) reasoning process. Instead of direct generation, the model is trained to decompose the task into four steps: analyzing layout and chart type, extracting data and colors, determining styling details, and finally synthesizing the complete code. This structured approach significantly reduces hallucinations and ensures high-fidelity reproduction.

Datasets and Evaluation

The authors introduced Chart2Code-160k, a massive dataset of 160,000 chart-code pairs across 27 chart types. This dataset was built using a "code-first" strategy, where LLM-generated code is executed and filtered for quality before being paired with its resulting image. Evaluation was conducted across several benchmarks, including ChartMimic (academic charts), Plot2Code (Matplotlib gallery), and ChartX (complex reasoning).

Key Results

ChartCoder demonstrates state-of-the-art performance, particularly in executability and visual fidelity. Despite its relatively modest 7B parameter count, it outperforms much larger models.

Quantitative comparison of ChartCoder against other models across various benchmarks.

On the ChartMimic benchmark, ChartCoder achieved a 91.4% execution rate, surpassing InternVL2-76B (83.2%). In terms of visual similarity, it scored 74.0, rivaling proprietary models like GPT-4o and significantly outperforming other open-source alternatives. Ablation studies confirmed that the Snippet-of-Thought method is critical for capturing the fine details necessary for high-fidelity generation.

Discussion and Insights

The success of ChartCoder highlights several key principles:

  • Code as a Lossless Representation: Code captures every coordinate and styling choice, making it a superior representation for chart understanding compared to lossy text summaries.
  • Backbone Specialization: Using a Code LLM backbone drastically reduces syntax errors and improves the model's ability to handle complex library arguments.
  • Resolution and Perception: An "Any Resolution" strategy allows the model to process high-resolution patches, which is essential for reading small axis labels and legend text.

Limitations and Future Work

Current limitations include the model's scale and OCR accuracy for long text strings. Future research will explore scaling the architecture to 30B+ parameters and expanding the visual-to-code capabilities to other domains, such as web development (HTML/CSS generation).

Summary updated

BibTeX
@inproceedings{zhao2025chartcoder,
  author = {Xuanle Zhao and Xianzhen Luo and Qi Shi and Chi Chen and Shuo Wang and Zhiyuan Liu and Maosong Sun},
  title = {{ChartCoder: Advancing Multimodal Large Language Model for Chart-to-Code Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.acl-long.363},
}
Figure