Module 2.4: Visualization Mastery

15 min Prerequisites: Previous modules

What You'll Learn

  1. All visualization functions in Tigramite
  2. When to use each plot type
  3. Customization options
  4. Creating publication-ready figures

Plot Types Overview

FunctionPurposeWhen to Use
plot_timeseries()Show raw dataAlways first!
plot_scatterplots()Check linearityBefore choosing test
plot_lagfuncs()Find optimal tau_maxBefore running PCMCI
plot_graph()Summary causal graphFinal results
plot_time_series_graph()Temporal causal graphDetailed analysis

1. plot_timeseries() - Always Start Here!

# Basic time series plot
tp.plot_timeseries(dataframe, figsize=(12, 6))
plt.show()

2. plot_scatterplots() - Check for Linearity

# Scatter plots to check if relationships are linear
tp.plot_scatterplots(dataframe=dataframe, figsize=(10, 10))
plt.show()

# If relationships look linear → use ParCorr
# If relationships are curved → use CMIknn

3. plot_lagfuncs() - Find Optimal tau_max

# Get lagged correlations
correlations = pcmci.get_lagged_dependencies(tau_max=20, val_only=True)['val_matrix']

# Plot lag functions
tp.plot_lagfuncs(
    val_matrix=correlations,
    setup_args={'var_names': var_names, 'x_base': 5}
)
plt.show()

# Look for where correlations become negligible
# Set tau_max to that value

4. plot_graph() - Summary Causal Graph

# Basic process graph
tp.plot_graph(
    graph=results['graph'],
    val_matrix=results['val_matrix'],
    var_names=var_names,
    figsize=(8, 6)
)
plt.show()

Publication-Quality Graph

tp.plot_graph(
    graph=results['graph'],
    val_matrix=results['val_matrix'],
    var_names=var_names,
    figsize=(10, 8),
    link_colorbar_label='MCI Strength',
    node_colorbar_label='Auto-MCI',
    show_autodependency_lags=True,
    node_size=0.4,
    arrow_linewidth=8,
    curved_radius=0.2
)
plt.show()

5. plot_time_series_graph() - Detailed Temporal View

# Shows exact lags
tp.plot_time_series_graph(
    graph=results['graph'],
    val_matrix=results['val_matrix'],
    var_names=var_names,
    figsize=(14, 6),
    link_colorbar_label='MCI Strength'
)
plt.show()

# This view shows WHEN effects occur (which lag)

Saving Figures

# Save as high-resolution PNG
fig, ax = plt.subplots(figsize=(10, 8))
tp.plot_graph(
    graph=results['graph'],
    val_matrix=results['val_matrix'],
    var_names=var_names,
    fig_ax=(fig, ax)
)

# Save with high DPI for publication
fig.savefig('causal_graph.png', dpi=300, bbox_inches='tight')
fig.savefig('causal_graph.pdf', bbox_inches='tight')  # Vector format

Quick Reference: Customization Options

tp.plot_graph(
    graph=results['graph'],
    val_matrix=results['val_matrix'],
    var_names=var_names,

    # Size and layout
    figsize=(10, 8),
    node_size=0.4,
    node_aspect=1.0,

    # Colors
    link_colorbar_label='Strength',
    node_colorbar_label='Auto-effect',
    cmap_edges='RdBu_r',
    cmap_nodes='OrRd',

    # Labels
    show_autodependency_lags=True,
    node_label_size=12,
    link_label_fontsize=10,

    # Arrows
    arrow_linewidth=8,
    curved_radius=0.2,
)