Matplotlib Figure Generator: Direct Inkscape Extension
The Matplotlib Figure Generator extension lets you create and edit Matplotlib visualizations directly inside Inkscape with full vector editability. No more export-import friction—build charts in Python, render as SVG, and edit every element (axes, labels, colors) as native Inkscape objects.
Generate Matplotlib Figures Inside Inkscape — Without Leaving Your Design Tool
You’ve spent 20 minutes perfecting a bar chart in Matplotlib. Now you need to drop it into your Inkscape poster—but the moment you export as PNG, it’s locked. You can’t edit the colors. You can’t move the legend. You can’t adjust the title without regenerating the whole thing in Python, exporting again, and re-importing.
There’s a better way. The Matplotlib Figure Generator extension lets you build and edit Matplotlib visualizations directly inside Inkscape, with full vector editability and zero export-import friction.
What This Is
The Matplotlib Figure Generator is an Inkscape extension that bridges Python visualization and vector design. It supports three modes—Inline Code, External File, and Data Template—letting you generate SVG or PNG figures from Matplotlib code without leaving Inkscape. Once rendered, every element (axes, labels, colors, markers) remains fully editable as vector objects.
Key benefit: Matplotlib figures become native Inkscape objects. No rasterization. No loss of quality on zoom. No locked-down exports.
Prerequisites
Before you start, verify you have:
- Inkscape 1.2 or later
- Python 3.7+ installed and accessible from your command line
- Matplotlib (
pip install matplotlib) - NumPy (auto-installed with Matplotlib)
- Optional: Pandas (for CSV/Excel import in Template mode)
- The Matplotlib Figure Generator extension (from the Inkscape extension repository)
Installation & Setup
Step 1: Install the Extension
Download the extension package and extract it. Copy the folder into your Inkscape extensions directory:
# Windows
C:\Users\[YourUsername]\AppData\Roaming\inkscape\extensions
# macOS
~/Library/Application Support/Inkscape/extensions
# Linux
~/.config/inkscape/extensions
Step 2: Verify Python Path
Open Inkscape and go to Edit → Preferences → System. Confirm the Python interpreter path points to your Python 3.7+ installation. If blank, add it manually (e.g., /usr/bin/python3 on macOS/Linux or C:\Python39\python.exe on Windows).
Step 3: Restart Inkscape
Close and reopen Inkscape to load the extension.
Step 4: Confirm Installation
Navigate to Extensions → Render → Matplotlib Figure Generator. A dialog with three mode tabs should appear. If not, double-check your Python path and folder permissions.
Core Workflow
Mode 1: Inline Code (Quick Plots)
Fastest for one-off visualizations. Paste Matplotlib code directly into Inkscape.
Step 1: Open Extensions → Render → Matplotlib Figure Generator.
Step 2: Click the Inline Code tab.
Step 3: Paste your Matplotlib code:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x, y, linewidth=2, color='#2E86AB')
plt.title('Sine Wave', fontsize=14, fontweight='bold')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.tight_layout()
Step 4: Choose output format:
- SVG — fully editable vector (recommended)
- PNG — fixed-resolution raster
Step 5: Configure optional settings:
- Transparent Background — removes white background
- Tight Layout — auto-fits margins
- DPI (PNG only) — set resolution (default 150)
- Style — choose Matplotlib style (e.g., “seaborn”, “ggplot”)
- Colormap — select color scheme
Step 6: Click Apply. The figure renders as a grouped object on your canvas.
Step 7: Ungroup and edit (SVG only). Right-click the figure and select Ungroup (Ctrl+Shift+G). Now select individual bars, lines, or text to change colors, stroke width, font size, or position.
Mode 2: External File (Reusable Scripts)
Use this for working Python scripts saved separately.
Step 1: Save a Matplotlib script as .py:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x, y, linewidth=2, color='#2E86AB')
plt.title('Sine Wave', fontsize=14, fontweight='bold')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.tight_layout()
Step 2: Open the extension and click the External File tab.
Step 3: Click Browse and select your .py file.
Step 4: Choose output format (SVG or PNG).
Step 5: Set style, colormap, and DPI as needed.
Step 6: Click Apply. The script executes in the background (2–5 seconds for complex plots), and the figure appears on your canvas.
Step 7: Ungroup to edit individual elements.
Mode 3: Template with Data Import (Dynamic Figures)
Powerful for research workflows. Load external data and inject it into a template script.
Step 1: Create a data file (models.csv):
model,accuracy,training_time
RandomForest,0.87,2.3
GradientBoosting,0.91,5.1
SVM,0.85,1.2
Step 2: Write a template script using variable names matching your data columns:
import matplotlib.pyplot as plt
plt.bar(model, accuracy, color='#E63946', alpha=0.8)
plt.ylabel('Accuracy Score')
plt.title('Model Performance Comparison')
plt.xticks(rotation=45)
Step 3: Open the extension and click the Template tab.
Step 4: Click Load Data and select your CSV/Excel file.
Step 5: Configure column mapping (e.g., “model” for X-axis, “accuracy” for Y-axis).
Step 6: Click Load Template Script and select your .py file.
Step 7: Click Apply. The extension injects your data into the template, runs Matplotlib, and renders the figure.
Step 8: Ungroup and customize colors, fonts, and layout.
Practical Example
Scenario: You’re preparing a research poster comparing three machine learning models.
Data file (models.csv):
model,accuracy
Model A,0.876
Model B,0.923
Model C,0.891
Template script (bar_chart_template.py):
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(8, 5))
bars = ax.bar(model, accuracy,
color=['#264653', '#2A9D8F', '#E76F51'],
edgecolor='black', linewidth=1.5)
ax.set_ylabel('Accuracy', fontsize=12, fontweight='bold')
ax.set_xlabel('Model', fontsize=12, fontweight='bold')
ax.set_title('ML Model Performance', fontsize=14, fontweight='bold')
plt.tight_layout()
In Inkscape: load the data file, select the template script, click Apply. A professional bar chart appears on your canvas—fully editable, no rasterization.
Common Issues & Fixes
Extension doesn’t appear in menu
Check that Python is correctly configured in Edit → Preferences → System. Restart Inkscape after updating the path.
“ModuleNotFoundError: No module named ‘matplotlib’”
Install Matplotlib in the Python interpreter Inkscape uses:
python -m pip install matplotlib numpy
SVG figure is pixelated or blurry
Verify you selected SVG format, not PNG. PNG is always raster; SVG is always vector.
Template mode: data not loading
Check that column names in your CSV exactly match variable names in your template script (case-sensitive).
Next Steps
Start with Inline Code for quick prototyping. Move to External File when you have reusable scripts. Graduate to Template mode when iterating on data-driven visualizations for posters, papers, or presentations.
Your figures become design objects—live, editable, and integrated into your workflow.
Which mode fits your workflow best—quick inline plots, external scripts, or data-driven templates? Reply and tell me what visualization challenge you’re solving.
What’s your current workflow for integrating Python visualizations into design projects—and how would direct Inkscape rendering change your process?
Comments