Scientific Visualization

Scientific Visualization automation and integration

Scientific Visualization is a community skill for creating data visualizations for scientific research, covering statistical plots, multi-panel figures, publication formatting, interactive displays, and domain-specific chart types for research communication.

What Is This?

Overview

Scientific Visualization provides tools for creating publication-quality data visualizations. It covers statistical plots that render scatter plots, box plots, violin plots, and heatmaps with proper statistical annotations, multi-panel figures that compose multiple related plots into unified figure layouts with shared axes, publication formatting that applies journal-specific styling including font sizes, color palettes, and dimension requirements, interactive displays that create explorable visualizations for supplementary materials and presentations, and domain-specific chart types that generate specialized visualizations like volcano plots, survival curves, and phylogenetic trees. The skill helps researchers visualize data effectively.

Who Should Use This

This skill serves researchers creating figures for journal publications, data scientists presenting analysis results to scientific audiences, and students learning to create effective scientific plots.

Why Use It?

Problems It Solves

Default plotting library outputs require significant customization to meet journal publication standards. Composing multiple related plots into coherent multi-panel figures with aligned axes takes manual effort. Domain-specific visualizations like volcano plots and Manhattan plots are not available as built-in chart types. Switching between journals requires reformatting figures to different specifications.

Core Highlights

Plot generator creates statistical visualizations with proper annotations. Panel composer arranges multiple plots into unified figures. Style manager applies journal-specific formatting rules. Domain plotter generates specialized scientific chart types.

How to Use It?

Basic Usage

import matplotlib.pyplot\
  as plt
import numpy as np

def pub_style():
  plt.rcParams.update({
    'font.size': 8,
    'font.family': 'Arial',
    'axes.linewidth': 0.8,
    'xtick.major.width':
      0.8,
    'ytick.major.width':
      0.8,
    'figure.dpi': 300})

def multi_panel(
  data: dict,
  output: str
):
  pub_style()
  fig, axes = plt.subplots(
    1, 3,
    figsize=(7, 2.5))

  # Panel A: scatter
  ax = axes[0]
  ax.scatter(
    data['x'], data['y'],
    s=10, alpha=0.6)
  ax.set_xlabel('X')
  ax.set_ylabel('Y')
  ax.set_title('A',
    loc='left',
    fontweight='bold')

  # Panel B: boxplot
  ax = axes[1]
  ax.boxplot(
    data['groups'])
  ax.set_xticklabels(
    data['labels'])
  ax.set_title('B',
    loc='left',
    fontweight='bold')

  # Panel C: bar
  ax = axes[2]
  ax.bar(
    data['categories'],
    data['values'])
  ax.set_title('C',
    loc='left',
    fontweight='bold')

  plt.tight_layout()
  fig.savefig(
    output, dpi=300,
    bbox_inches='tight')
  plt.close(fig)

np.random.seed(42)
multi_panel({
  'x': np.random.randn(50),
  'y': np.random.randn(50),
  'groups': [
    np.random.randn(30)
    for _ in range(3)],
  'labels': ['A', 'B', 'C'],
  'categories': [
    'G1', 'G2', 'G3'],
  'values': [4.2, 3.1, 5.8]
}, 'figure1.png')

Real-World Examples

import matplotlib.pyplot\
  as plt
import numpy as np

class VolcanoPlot:
  def __init__(
    self,
    log2fc: np.ndarray,
    pvalues: np.ndarray,
    genes: list[str]
  ):
    self.fc = log2fc
    self.pval = (
      -np.log10(pvalues))
    self.genes = genes

  def plot(
    self,
    fc_thresh: float = 1.0,
    p_thresh: float = 2.0,
    output: str =
      'volcano.png'
  ):
    fig, ax = plt.subplots(
      figsize=(5, 4))

    sig = (
      (np.abs(self.fc)
        > fc_thresh) &
      (self.pval
        > p_thresh))
    ax.scatter(
      self.fc[~sig],
      self.pval[~sig],
      c='grey', s=5,
      alpha=0.5)
    ax.scatter(
      self.fc[sig],
      self.pval[sig],
      c='red', s=10)

    ax.axhline(
      p_thresh,
      ls='--', c='grey')
    ax.axvline(
      fc_thresh,
      ls='--', c='grey')
    ax.axvline(
      -fc_thresh,
      ls='--', c='grey')
    ax.set_xlabel(
      'Log2 Fold Change')
    ax.set_ylabel(
      '-Log10 P-value')

    fig.savefig(
      output, dpi=300,
      bbox_inches='tight')
    plt.close(fig)

np.random.seed(42)
n = 5000
vp = VolcanoPlot(
  np.random.randn(n),
  np.random.uniform(
    0, 1, n),
  [f'G{i}' for i
    in range(n)])
vp.plot()

Advanced Tips

Define a reusable style function that sets matplotlib rcParams to match your target journal specifications. Use constrained_layout instead of tight_layout for complex multi-panel figures with colorbars. Save figures in both PNG and SVG formats to cover different submission requirements.

When to Use It?

Use Cases

Create a multi-panel figure with scatter plot, box plot, and bar chart for a journal submission. Generate a volcano plot to visualize differentially expressed genes. Build a reusable figure style template matching specific journal formatting requirements.

Related Topics

Data visualization, matplotlib, scientific figures, publication graphics, statistical plots, and research communication.

Important Notes

Requirements

Python visualization libraries including matplotlib and numpy for plotting and data handling. Knowledge of target journal figure specifications for dimensions and resolution. Data in structured formats for programmatic plot generation.

Usage Recommendations

Do: use colorblind-friendly palettes for all scientific figures. Set figure dimensions to match journal column widths before creating the plot. Add statistical annotations directly to plots rather than describing them only in captions.

Don't: use 3D charts when 2D representations convey the same information more clearly. Apply different styles to figures within the same manuscript. Rely on color alone to distinguish categories since printed versions may be grayscale.

Limitations

Programmatic figure generation requires coding skill that may be slower than interactive tools for simple plots. Matplotlib defaults often need significant customization for publication quality. Some specialized scientific plot types may require domain-specific libraries beyond standard visualization tools.