Why this matters
As a Data Visualization Engineer, your work becomes valuable only when others can see and use it. You will export charts for slide decks, save publication-ready figures for reports, ship interactive HTML for stakeholders, and automate delivery for recurring updates. Strong exporting and sharing habits make your outputs reliable, consistent, and easy to consume.
- Create high-DPI images for reports and presentations.
- Publish interactive HTML charts that open in any modern browser.
- Bundle assets so that teammates get exactly what you see on your machine.
- Automate weekly outputs with stable filenames and metadata.
Concept explained simply
Exporting is turning your code output (charts, tables, dashboards) into files people can open: PNG, SVG, PDF, or self-contained HTML. Sharing is making sure the right people get the right file, in the right quality and format, at the right time.
Tip: Vector vs. Raster
Vector formats (SVG, PDF) scale infinitely and are great for logos, line charts, and print. Raster formats (PNG, JPG) are fixed-resolution snapshots—good for screenshots, heatmaps, and complex images. PNG supports transparency; JPG does not.
Tip: Interactive vs. Static
Interactive HTML lets users hover, filter, or zoom. Static images are lightweight, stable, and easy to paste into slides or docs. When in doubt, ship both: interactive for exploration and static for communication.
Mental model
- Capture: Render exactly what you want (size, DPI, styles, fonts).
- Package: Choose the right format(s) and embed assets (fonts, data if needed).
- Deliver: Name files clearly, compress if needed, and share to the correct channel.
- Verify: Open the file on a second device; check size, readability, and interactivity.
Formats and when to use
- PNG: Slides, docs, email previews. Use 2x or 3x target resolution for sharpness.
- SVG: Scalable charts, logos, and diagrams. Ideal for vector line/bar charts.
- PDF: Print-ready documents; preserves vector quality and page layout.
- HTML (self-contained): Interactive charts that open in any browser without servers.
- CSV/JSON: Data extracts that accompany visuals when stakeholders need raw data.
- GIF/MP4: Simple animations or walkthroughs; keep file sizes small.
Worked examples
Example 1 — Python (Matplotlib): Export PNG + SVG, consistent sizing
# Requires: matplotlib, seaborn (optional)
import matplotlib.pyplot as plt
import seaborn as sns
# Example data
penguins = sns.load_dataset("penguins").dropna()
# Render
plt.figure(figsize=(8, 4.5), dpi=300) # 8x4.5 inches, 300 DPI for print-quality
sns.scatterplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species")
plt.title("Penguin Bills")
plt.tight_layout()
# Export raster (PNG)
plt.savefig("penguin_bills.png", dpi=300, bbox_inches="tight")
# Export vector (SVG)
plt.savefig("penguin_bills.svg", format="svg", bbox_inches="tight")
plt.close()
Result: penguin_bills.png (high-DPI raster) and penguin_bills.svg (vector for crisp scaling).
Example 2 — Python (Plotly): Export interactive HTML + static fallback
# Requires: plotly; for static image export, install 'kaleido'
import plotly.express as px
import plotly.io as pio
fig = px.scatter(px.data.iris(), x="sepal_width", y="sepal_length", color="species", title="Iris Scatter")
# Interactive (self-contained) HTML
pio.write_html(fig, file="iris_scatter.html", include_plotlyjs="cdn", full_html=True)
# Static fallback (PNG) — requires kaleido
try:
fig.write_image("iris_scatter.png", scale=2) # 2x scale for sharpness
except Exception as e:
print("Static export skipped (install kaleido to enable).", e)
Share iris_scatter.html for interaction, plus iris_scatter.png for easy embedding.
Example 3 — Browser (JS/SVG): Export SVG and open a PNG snapshot
Assume your chart is an <svg id="chart">...
// 1) Serialize SVG to a string
const svg = document.getElementById('chart');
const serializer = new XMLSerializer();
let svgStr = serializer.serializeToString(svg);
// Ensure a white background for PNG
if (!svgStr.includes('style="background')) {
svgStr = svgStr.replace('
This opens a PNG snapshot in a new tab so you can Save Image.
Sharing approaches
- Ad hoc: Send a PNG for quick viewing and an SVG/PDF for editing/print. Add a one-line context summary.
- Recurring: Script exports to a stable folder with consistent filenames (include date or version).
- Accessible: Provide alt text and a brief takeaway in the message body.
Message template you can copy
Subject: Weekly KPI – Conversion Rate
Files: kpi_conversion_2025-01-05.png (slide-ready), kpi_conversion_2025-01-05.svg (vector)
Notes: Conversion up +0.8pp WoW. Main driver: mobile traffic quality.
Alt: Line chart showing steady increase from 2.4% to 3.2% over 8 weeks.
Export settings checklist
- Size: Set explicit width x height (pixels for PNG, inches + DPI for print).
- DPI: 300 for print; 144–192 for screens when you need sharpness.
- Fonts: Use common fonts or embed (SVG/PDF). Avoid layout shifts.
- Colors: Ensure contrast; avoid relying solely on color to convey meaning.
- Background: White or transparent as needed; avoid unintended grey.
- Legibility: Axis labels ≥ 10–12 pt (print) or clearly readable on target screen.
- Metadata: Include source and date in footer or filename when appropriate.
- Interactivity: For HTML, verify tooltips, zoom, and responsive sizing.
Versioning and reproducibility
- File naming: project_output_YYYY-MM-DD.ext or project_output_v1.2.ext
- Determinism: Fix random seeds and filter dates in code for stable outputs.
- One command: Wrap exports in a single script function so anyone can rerun.
- Self-check: Rebuild the file on a second machine or environment before sharing widely.
Access and privacy
- Remove PII unless absolutely required; aggregate or mask sensitive fields.
- Trim data to minimum necessary for the story.
- Include a short data sensitivity note if content is internal-only.
Exercises
Do these to lock in the skill. Mirror of the graded exercises below.
- Exercise 1: Export a publication-ready chart in Python as PNG (300 DPI) and SVG. Verify size and clarity.
- Checklist: explicit figure size; PNG 300 DPI; SVG vector; tight layout; readable labels.
- Exercise 2: From a browser-based SVG chart, open a 2x PNG snapshot in a new tab with a white background.
- Checklist: white background; 2x scale; correct width/height; legible text.
Common mistakes and how to self-check
- Blurry images: Forgot DPI or exported too small. Fix: set figure size and DPI explicitly.
- Cut-off labels: Missing tight layout. Fix: use bbox_inches="tight" or layout pads.
- Font changes on other machines: Non-embedded fonts. Fix: embed fonts in SVG/PDF or use common fonts.
- Huge HTML files: Embedded datasets too large. Fix: downsample or provide data separately.
- Dark-mode surprises: Transparent background becomes unreadable. Fix: set explicit background color.
Mini challenge
Create one interactive HTML chart plus a static PNG fallback for the same view. Name them consistently, add a one-sentence takeaway, and verify on a second device. Aim to keep the HTML under 3 MB.
Quick Test
Everyone can take the test; only logged-in users get saved progress.