Module 4 · Interactive Visualization with Plotly

Section 2: Advanced Interactive Visualizations

Graph Objects · Multi-Trace · Dropdown Menus · Range Sliders · Animations

🧱 Graph Objects (go)
  • Low-level API: import plotly.graph_objects as go
  • Build trace-by-trace: go.Scatter(), go.Bar()
  • Combine multiple trace types in one figure
  • Use when Plotly Express limits are reached
🔀 Multi-Trace Figures
  • fig.add_trace(go.Scatter(...)) to layer traces
  • Mix bar and line charts on the same axes
  • Add reference lines: fig.add_hline(y=target)
  • Secondary y-axis via secondary_y=True
🎛️ Dropdown Menus
  • updatemenus in fig.update_layout()
  • Toggle trace visibility or change chart type
  • Buttons or dropdowns — configure with type param
  • Enable viewers to self-serve analysis without code
🎚️ Range Sliders & Selectors
  • fig.update_xaxes(rangeslider_visible=True)
  • Quick-select buttons: 1M, 3M, 6M, YTD, 1Y, All
  • Essential for long time-series financial data
  • rangeselector dict for custom button configuration
🎬 Advanced Animations
  • animation_frame + animation_group for tracking
  • Transition: frame.duration, transition.duration
  • Animated scatter shows bubble charts over time
  • Stable axis ranges prevent jarring scale jumps
🧪 Lab 2 — Advanced Interactivity
  • Part A: Multi-metric performance dashboard with dropdowns
  • Part B: Animated market share evolution bubble chart
  • Add range slider to a time-series financial chart
  • Combine bar and line traces on secondary y-axis