Visualizing Scientific Data in Veusz: Best Practices and ExamplesVeusz is a free, open-source scientific plotting package designed for creating publication-quality figures. It offers an accessible GUI, a scriptable Python API, and a focus on reproducibility and precision—making it well suited for researchers who need reliable, high-quality visualizations without steep learning curves. This article covers best practices for preparing, plotting, and exporting scientific figures in Veusz, along with practical examples and tips for common tasks.
Why choose Veusz?
- Lightweight and focused: Veusz concentrates on plotting and figure assembly rather than being a full scientific computing stack.
- GUI + scripting: Use the GUI for interactive work and the Python API or saved project files for reproducibility.
- Vector output: Exports to PDF, SVG, and PostScript for crisp figures suitable for journals.
- Data flexibility: Reads many formats (CSV, FITS, HDF5 via plugins) and handles complex multi-panel figures, annotations, and custom axes.
Preparing your data
Good visualization begins with clean, well-structured data.
- Use plain columnar formats (CSV, TSV) or NumPy/Pandas-compatible structures for easy import.
- Keep units and metadata consistent. If mixing datasets, convert to common units before plotting.
- Remove or flag outliers and missing values explicitly; Veusz can plot masked data but preprocessing keeps plots clear.
- Reduce data volume where necessary. For very dense datasets, consider binning, downsampling, or plotting density estimates.
Example workflow with Python (pseudocode):
import pandas as pd df = pd.read_csv("measurements.csv") df = df.dropna(subset=["time", "signal"]) df["signal"] = df["signal"] * 1e3 # convert units
Project structure and reproducibility
- Save Veusz projects (.vsz) to preserve layout, axis settings, and data links.
- Use the Python API or export an equivalent script to recreate figures. Treat the script as part of the analysis pipeline.
- Parameterize scripts (file paths, axis ranges, colors) so figures can be regenerated for multiple datasets or updated analyses.
Example: keep a short script to regenerate figure from CSV, with configurable path and output filename.
Designing clear scientific plots
Principles that apply in Veusz as in other plotting tools:
- Prioritize clarity: each figure should convey one main idea.
- Use appropriate scales: linear, log, or symlog depending on data distribution.
- Label axes with quantities and units: e.g., “Concentration (µM)”.
- Keep fonts consistent and readable; journals often require specific font sizes—Veusz lets you set font families and sizes precisely.
- Use color and line styles for differentiation, not decoration. Ensure contrast for print and colorblind readers (avoid relying solely on hue; use markers/linestyles).
Practical tips in Veusz:
- Use the Axis → Ticks and Axis → Labels panels to control tick frequency, formatting, and units.
- For multi-panel figures, create a grid of plots under a single canvas; share axes when appropriate to reduce redundancy.
- Use the Legend object for multiple curves; manually control placement and spacing to avoid overlap.
Common plot types and examples
Below are workflows and settings for typical scientific plot types in Veusz.
1. Line plot with error bars
- Import X, Y, and Yerr columns.
- Use a Line plot for the main curve and an Error bars object for uncertainties.
- Set line width, marker size, and error bar cap size in the object properties.
- For publication, use a thin line (0.8–1.5 pt) and distinguish markers only where needed.
Example:
- Data: time (s), measurement, uncertainty
- Axis: time on x, measurement on y
- Style: black line, circular markers, gray error bars
2. Scatter plot with density/color mapping
- For large point clouds, consider plotting a 2D histogram or density map.
- Use a Scatter object for smaller datasets; set marker alpha for overplotting.
- Use the Color map object for representing a third variable.
Example:
- X: gene expression, Y: protein abundance, color: sample condition
- Use colorblind-friendly palettes and include a colorbar with units.
3. Histogram and KDE overlays
- Use Histogram object for bin counts and optionally overlay a smoothed Kernel Density Estimate generated externally (e.g., with SciPy) and plotted as a Line.
- Match scales and normalize if comparing distributions from different sample sizes.
4. Contour plots and heatmaps
- For gridded data, use Image (heatmap) or Contour objects.
- Control interpolation, color maps, and contour levels via properties.
- Add contour labels or a colorbar to aid interpretation.
5. Multi-panel figures (insets, grid layouts)
- Create a Canvas and add multiple Plot objects arranged in rows/columns.
- Use shared axes or manually align axis ranges for consistent comparison.
- Create inset plots by placing a small Plot object above the main plot and linking its data source to a subset of the main dataset.
Styling and aesthetics
- Fonts: set in Canvas → Style or per-object to match journal requirements.
- Line widths: 0.5–1.5 pt for publication lines, heavier for emphasis.
- Marker sizes: avoid overly large markers; use distinct shapes when color alone is insufficient.
- Color maps: prefer perceptually uniform maps (e.g., Viridis) for continuous data; diverging maps for data centered on a meaningful mid-point.
- Export resolution: prefer vector formats (PDF, SVG). For raster (PNG, TIFF), export at 300–600 dpi depending on journal instructions.
Annotations and labeling
- Add text objects for annotations, arrows for pointing to features, and shaded regions for highlighting ranges.
- Use LaTeX-style math by enabling TeX rendering where available for axis labels and annotations (Veusz supports basic TeX in text).
- Keep annotations minimal and precise—too many callouts clutter the figure.
Scripting and automation
- Use Veusz’s Python module (veusz) to script figure creation for reproducibility and batch generation.
- Example uses: regenerating figures for multiple datasets, programmatically adjusting axis limits, automating export to multiple formats.
- Structure scripts with functions for data loading, styling, and exporting so they’re easy to reuse.
Minimal pseudo-example:
from veusz import Veusz v = Veusz() v.loadData('data.csv') v.addPlot('graph') v.plotLine(x='col1', y='col2') v.save('figure.pdf')
(Refer to Veusz API docs for exact calls and parameters.)
Exporting for publication
- Prefer vector formats (PDF, SVG, EPS). Convert to TIFF only if the journal requires raster images.
- Check font embedding: ensure fonts are embedded or use standard fonts to avoid substitution.
- Verify line widths and marker sizes at final print scale—export a PDF and preview at 100% to confirm legibility.
- For multi-panel figures, export the whole canvas as a single file to preserve layout.
Troubleshooting common issues
- Blurry text in exported PDFs: check font embedding and use vector output; avoid converting text to paths unnecessarily.
- Long load times with huge datasets: downsample or use decimated views for interactive work and full-resolution export from scripts.
- Color reproduction problems: preview in grayscale to ensure interpretability; choose high-contrast palettes.
Example: From raw CSV to publication figure (concise workflow)
- Clean and preprocess data in Python/Pandas (handle NaNs, convert units).
- Load CSV into Veusz GUI or script.
- Create Plot object(s): set axis labels, scales, and limits.
- Add Line/Scatter/Error objects; style lines, markers, and colors.
- Add legend and annotations.
- Arrange multi-panel layout if needed.
- Export to PDF/SVG and check fonts, line weights, and legibility.
Final tips
- Keep figures simple and focused—each panel should make one clear point.
- Use the GUI for interactive exploration and the Python API for reproducible exports.
- Test exports at final intended size and resolution early to catch layout and legibility issues.
Veusz is an efficient tool for researchers who need precise control and reproducible, publication-ready figures. With careful data preparation, consistent styling, and scripted automation when appropriate, you can produce clear, accurate visualizations suitable for journals, presentations, and reports.
Leave a Reply