Menu

Matrix Visualization

Beautiful Heatmaps with Clustering

Heatmaps transform matrices of numbers into color-encoded patterns that reveal correlations, clusters, and outliers at a glance. From gene expression to survey data, Plotivy creates publication-ready heatmaps with automatic clustering.

Types of Heatmaps in Science

Correlation Heatmap

Shows pairwise Pearson/Spearman correlations. Use triangular mask to avoid redundancy. Best for feature selection and multicollinearity detection.

Clustered Heatmap

Gene expression or abundance matrices with hierarchical clustering dendrograms. Standard in RNA-seq, proteomics, and microbiome studies.

Annotated Heatmap

Confusion matrices, contingency tables, or performance metrics with numeric annotations inside each cell. Common in ML and clinical studies.

Is a Heatmap the Right Choice?

A quick check to choose heatmaps confidently and avoid overcomplicated figures.

Use a heatmap when

  • You need to compare many values across rows and columns at once.
  • Patterns, gradients, or clusters matter more than exact single values.
  • You want to pair matrix data with hierarchical clustering or annotations.

Pick another chart when

  • You need precise value comparisons for only a few variables.
  • Your audience is non-technical and needs direct numeric readability.
  • Feature count is low - consider a box plot or compare alternatives in the chart gallery.

Live Code Lab: Correlation Heatmap

This code creates a lower-triangle correlation heatmap with annotated r-values, a diverging colormap, and publication-ready styling. Edit and run instantly.

Live Code Editor
Code EditorPython
Loading editor...
Live Preview

Preparing preview

Running once automatically on first load

Learn by Experimenting

This is a safe playground for learning! Try changing:

  • • Colors: Modify color values to see different palettes
  • • Numbers: Adjust sizes, positions, or data ranges
  • • Labels: Update titles, axis names, or legends

Edit the code, run it, then open the full data visualization tool to continue with your own dataset.

Design tips for heatmaps

  • Colormap choice: use RdBu_r for diverging data (correlations), viridis for sequential
  • Mask diagonal: self-correlations (always 1.0) are uninformative - mask them
  • Spearman vs Pearson: use df.corr(method="spearman") for non-linear relationships
  • Cluster ordering: reorder variables by hierarchical clustering to reveal blocks

Bonus: Clustered Heatmap with Dendrograms

The gold standard for gene expression visualization. This code creates a heatmap with row and column dendrograms showing hierarchical clustering - all from scratch.

Live Code Editor
Code EditorPython
Loading editor...
Live Preview

Preparing preview

Running once automatically on first load

Learn by Experimenting

This is a safe playground for learning! Try changing:

  • • Colors: Modify color values to see different palettes
  • • Numbers: Adjust sizes, positions, or data ranges
  • • Labels: Update titles, axis names, or legends

Edit the code, run it, then open the full data visualization tool to continue with your own dataset.

Why Scientists Choose Plotivy for Heatmaps

Auto-scaling & normalization

Plotivy detects your data range and applies z-score normalization or min-max scaling to ensure clear color contrast.

Hierarchical clustering

Ward, complete, average, or single linkage clustering applied to rows and columns with dendrograms drawn automatically.

Smart colormaps

Diverging colormaps for correlations, sequential for counts, and perceptually uniform options for accessibility.

Export at any size

Heatmaps with 50+ features export cleanly at 300 DPI with readable labels and proper aspect ratios.

Chart gallery

Related Visualization Types

Explore more ways to visualize matrices and patterns

Browse all chart types →
Scatter plot of height vs weight colored by gender with regression line
Statistical•matplotlib, seaborn
From the chart gallery•Correlation analysis between metrics

Scatterplot

Displays values for two variables as points on a Cartesian coordinate system.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
import pandas as pd

# Generate sample data
np.random.seed(42)
n_samples = 200
height = np.random.normal(170, 8, n_samples)
weight = height * 0.6 + np.random.normal(0, 8, n_samples) - 50
Bar chart comparing average scores across 5 groups with error bars
Comparison•matplotlib, seaborn
From the chart gallery•Comparing performance across categories

Bar Chart

Compares categorical data using rectangular bars with heights proportional to values.

Sample code / prompt

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats

# Generate performance scores for 5 treatment groups
np.random.seed(42)
groups = ['Control', 'Treatment A', 'Treatment B', 'Treatment C', 'Treatment D']
n_samples = 30
Radar chart comparing performance metrics of two models
Comparison•matplotlib, plotly
From the chart gallery•Product feature comparison

Radar Chart

Displays multivariate data on axes starting from a central point.

Sample code / prompt

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
import pandas as pd

# EV Model comparison data (0-100 scale)
categories = ['Range', 'Acceleration', 'Charging Speed',
              'Interior Quality', 'Technology', 'Value']
tesla_scores = [85, 90, 88, 70, 95, 80]
bmw_scores = [70, 80, 75, 90, 85, 65]
Histogram showing age distribution with 20 bins and KDE overlay
Distribution•matplotlib, seaborn
From the chart gallery•Analyzing age demographics

Histogram

Displays the distribution of numerical data by grouping values into bins.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import gaussian_kde, skewnorm

# Generate age data with slight right skew
np.random.seed(42)
ages = skewnorm.rvs(a=2, loc=42, scale=15, size=500)
ages = np.clip(ages, 18, 80)  # Clip to realistic range

fig, ax = plt.subplots(figsize=(12, 7))

Transform Your Data Matrix into Insight

Upload a CSV and Plotivy creates clustered, annotated heatmaps ready for your next publication.