metadata
pretty_name: Matplotlib Code-Image Pairs
license: other
tags:
- matplotlib
- code
- plotting
- computer-vision
- synthetic
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
dataset_info:
features:
- name: image
dtype: image
- name: code
dtype: string
- name: example_id
dtype: string
- name: figure_index
dtype: int64
- name: figure_name
dtype: string
- name: title
dtype: string
- name: example_page_url
dtype: string
- name: source_url
dtype: string
- name: source_relpath
dtype: string
- name: category_hint
dtype: string
- name: status
dtype: string
- name: num_figures
dtype: int64
- name: error
dtype: 'null'
splits:
- name: train
num_bytes: 57044107
num_examples: 643
download_size: 54960557
dataset_size: 57044107
Matplotlib Code-Image Pairs
Dataset Summary
This dataset contains static Matplotlib figure images paired with the Python source code that generated them. It was built from the official Matplotlib gallery and excludes animation-style examples. Each row corresponds to one rendered image. Examples that produce multiple figures contribute multiple rows.
Dataset Composition
- Image/code rows: 643
- Source examples: 452
- Examples with multiple figures: 74
- Included statuses: ok
- Source gallery: https://matplotlib.org/stable/gallery/index.html
Top Categories
lines_bars_and_markers: 48 examplesimages_contours_and_fields: 47 examplestext_labels_and_annotations: 46 examplesmplot3d: 44 examplessubplots_axes_and_figures: 35 examplesmisc: 25 examplesticks: 24 examplesaxes_grid1: 22 examplesstatistics: 21 examplesevent_handling: 20 examples
Row Schema
image: rendered PNG for one figurecode: full Python source for the exampleexample_id: stable identifier derived from the Matplotlib gallery URLfigure_index: zero-based figure index within the examplefigure_name: original rendered image filenametitle: example page titleexample_page_url: Matplotlib gallery page URLsource_url: downloadable Python source URL when availablesource_relpath: source filename reported by the scrapercategory_hint: rough gallery category inferred from the URL pathstatus: scraper/render status kept for provenancenum_figures: number of figures reported for the source exampleerror: render or scrape error text, usually null for successful rows
Build Process
- Crawl the official Matplotlib gallery.
- Download the Python source for each example page.
- Render examples with Matplotlib's non-interactive
Aggbackend. - Keep static rendered image/code pairs and skip dynamic animation-style examples.
- Export one dataset row per rendered image.
Usage
Load the local saved dataset:
from datasets import load_from_disk
ds = load_from_disk("/usr/project/xtmp/ap843/hf_datasets/matplotlib_code_image_pairs")["train"]
Load from the Hugging Face Hub after pushing:
from datasets import load_dataset
ds = load_dataset("ajayvikram/matplotlib-code-image", split="train")