CorrPlot (Correlation Plot with Dendrogram) Examples
This page demonstrates the interactive CorrPlot chart type in JSPlots.
Browser-based hierarchical clustering: Dendrogram computed dynamically in your browser
Dual correlation display: Pearson (upper right) and Spearman (lower left) correlations in one matrix
Julia-computed correlations: Use compute_correlations() and prepare_corrplot_data() convenience functions
Flexible clustering: Choose linkage method (Ward, Average, Single, Complete) in browser
Automatic ordering: Variables reordered by clustering for clearer patterns
Works with subsets: Dendrogram updates dynamically when you select a subset of variables
Example 1: Financial Metrics Correlation Analysis
Analyze correlations between various financial metrics for companies.
This example demonstrates:
10 financial metrics tracked for 100 companies
Computing both Pearson and Spearman correlations in Julia
Hierarchical clustering with Ward linkage
Compare Pearson vs Spearman correlations to detect non-linear relationships
Variables automatically reordered by clustering to reveal patterns
Financial Metrics Correlation Analysis
This correlation plot shows relationships between financial metrics. The dendrogram groups similar metrics based on correlation patterns using hierarchical clustering performed in your browser. Variables are automatically reordered by clustering to reveal correlation blocks. Top-right triangle shows Pearson correlations (linear relationships), while bottom-left shows Spearman correlations (rank-based, captures non-linear monotonic relationships). Try this: Change the clustering linkage method (Ward/Average/Single/Complete) to see different groupings, or select a subset of variables to see how the dendrogram updates dynamically.
Data: financial_corr_data
Example 2: Sales Performance Metrics
Examine correlations between sales KPIs using average linkage clustering.
Features:
Multiple sales metrics: revenue, units, conversion rate, customer satisfaction, etc.
Average linkage clustering (different from Ward linkage in Example 1)
Identify which metrics move together
Detect leading indicators through correlation patterns
Sales Performance Metrics Correlation
Explore how different sales and operational metrics relate to each other. The dendrogram reveals which metrics cluster together using hierarchical clustering performed in your browser. For example, you might see that customer satisfaction groups with response time, while revenue metrics cluster separately. Try this: Change the clustering linkage method to Average or Single to see how it compares to Ward linkage.
Data: sales_corr_data
Example 3: Scientific Measurements - Single Linkage Clustering
This example demonstrates single linkage clustering (nearest neighbor).
Features:
Physical and chemical measurements from laboratory experiments
Demonstrates 'single' linkage clustering
Single linkage tends to create elongated clusters
Compare this dendrogram shape to Ward (Example 1) and average (Example 2) linkage
Scientific Measurements Correlation
This correlation plot reveals clusters of related physical, thermal, chemical, and spectroscopic properties. The hierarchical clustering groups density-related properties together, thermal properties in another cluster, and spectroscopic measurements in a third cluster. The dual correlation display (Pearson vs Spearman) helps identify non-linear relationships. Try this: Switch to Single linkage to see elongated clusters formed by merging based on nearest neighbors, or try Complete linkage for more compact clusters.
Data: science_corr_data
Example 4: Healthcare Patient Metrics - Complete Linkage
Analyze correlations between patient health indicators using complete linkage clustering.
This example includes:
Vital signs, lab results, and outcome metrics
Complete linkage clustering (farthest neighbor)
Identify risk factor correlations
Compare linear (Pearson) vs monotonic (Spearman) relationships
Patient Health Metrics Correlation
This correlation analysis helps identify relationships between vital signs, lab results, and cardiovascular risk. The hierarchical clustering reveals natural groupings: blood pressure metrics cluster together, lipid panel values form another group, and glucose-related metrics cluster separately. Compare Pearson (upper right) vs Spearman (lower left) correlations to see if relationships are linear or non-linear. Try this: Switch to Complete linkage clustering (farthest neighbor) to see compact, well-separated clusters.
Data: patient_corr_data
Example 5: Advanced CorrPlot - Economic Indicators Across Regions
Compare economic indicator correlations across different geographic regions:
Three regional scenarios: North America, Europe, Asia-Pacific
Variable selection: Choose which economic indicators to analyze
Compare patterns: See how indicator relationships vary by region
Useful for international portfolio analysis and macroeconomic research
Insights to explore:
How does GDP correlate with unemployment differently across regions?
Are inflation-interest rate relationships similar globally?
Which indicators cluster together in each region?
Economic Indicators - Regional Comparison
Compare how economic indicators correlate across North America, Europe, and Asia-Pacific. Switch between regions using the scenario selector to see different correlation patterns. The dendrogram updates automatically showing how indicators cluster in each region. Select specific indicators to focus your analysis. Notice how GDP Growth correlates differently with other indicators in each region, reflecting different economic structures and policies. Try this: Change the linkage method to see how clustering patterns differ.
Data: econ_adv_data
Example 6: Advanced CorrPlot - Climate Variables by Season
Analyze how climate variable correlations change across seasons:
Four seasonal scenarios: Spring, Summer, Fall, Winter
Interactive variable selection: Focus on specific climate factors
Seasonal patterns: See how temperature-humidity relationships vary
Demonstrates that correlation structure can change with context (season)
Key observations:
Temperature-humidity correlations differ by season
Precipitation patterns cluster differently in summer vs winter
Solar radiation shows different relationships across seasons
Climate Variable Correlations - Seasonal Analysis
Explore how climate variable correlations change across seasons. Switch between Spring, Summer, Fall, and Winter using the scenario selector to see seasonal patterns. The dendrogram updates dynamically showing how variables cluster in each season. Notice how Temperature-Humidity correlations flip between seasons (negative in Spring/Fall, positive in Summer/Winter). Use variable selection to focus on specific climate factors. Try manual ordering to group related variables by type (temperature-related, precipitation-related, etc.).
Data: climate_adv_data
Summary
The CorrPlot chart type provides:
Browser-based hierarchical clustering: Dendrogram computed dynamically in your browser, updates instantly when you change variables or linkage method
Dual correlation display:
Top-right triangle: Pearson correlation (measures linear relationships)
Bottom-left triangle: Spearman correlation (measures monotonic relationships, robust to outliers)
Julia-computed correlations: Use compute_correlations() for both Pearson and Spearman, then prepare_corrplot_data() to format for CorrPlot
Flexible clustering: Choose linkage method in browser (Ward, Average, Single, Complete) and see dendrogram update instantly
Works with subsets: Select any subset of variables and dendrogram reclusters automatically
Multiple scenarios: Compare correlations across different conditions (regions, seasons, etc.) using the scenario selector
Automatic ordering: Variables reordered by clustering results for clearer visualization of correlation blocks
Basic Workflow (Examples 1-4)
# 1. Compute correlations
vars = [:var1, :var2, :var3, :var4]
cors = compute_correlations(df, vars)
# 2. Prepare correlation data for CorrPlot
corr_data = prepare_corrplot_data(cors.pearson, cors.spearman, string.(vars))
# 3. Create correlation plot (clustering happens in browser!)
corrplot = CorrPlot(:my_corr, corr_data, :my_data;
title="My Correlation Analysis",
notes="Description...")
Advanced Workflow with Multiple Scenarios (Examples 5-7)