q.plot.correlation creates an interactive Plotly scatterplot matrix for exploring relationships among numeric features. Box or lasso selection is linked across every panel, and the observation timestamp is included in the hover context.
This example uses qrt’s bundled AAPL history, so it executes without a network connection. It deliberately combines related trend descriptors to make the feature structure easy to see. Strong relationships here indicate potential redundancy or multicollinearity; they do not by themselves establish predictive value.
Build market features
The feature set compares five- and twenty-session momentum with price relative to its 20-day average and the spread between 20-day EMA and 100-day SMA. These related trend measurements produce cleaner relationships than mixing trend, volatility, and volume in every panel.
The five-session forward return remains evaluation context only: it is deliberately excluded from the plotted feature dimensions to avoid presenting future information as a model input.
The regime is defined from AAPL’s own 20-day EMA relative to its 100-day SMA: below -2% is risk-off, above 2% is risk-on, and the middle band is neutral. Because trend_20d_100d drives that definition, its color separation is intentionally clear rather than accidental.
color_by="regime" is an explicit column lookup: the input DataFrame must contain a column named regime. QRT does not infer that column, interpret its name, or calculate the regime boundaries. For each row, it reads the value already stored in features["regime"]; color_discrete_map then maps values such as "risk-off" to their specified colors. A text, categorical, or boolean color_by column uses discrete colors, while a numeric column uses color_continuous_scale.
The helper defaults to a full matrix with visible diagonal panels, high-contrast markers, dark boxed subplot axes, and outward ticks. Legend entries can be hidden or isolated, and selecting observations in one panel highlights them throughout the matrix.
Use color_continuous_scale for a numeric color variable. The default is "RdYlGn"; it also accepts Plotly scale names such as "RdBu", "Viridis", or "Cividis". Append _r to reverse a named scale, for example "RdYlGn_r".
The feature-feature geometry remains clean, but the forward-return colors are more mixed. That contrast is useful: correlated inputs can be redundant without having a simple relationship to future returns. QRT centers the color scale at zero, with red for losses and green for gains by default.
fig = q.plot.correlation( features, columns=feature_columns, color_by="forward_return_5d", hover_data=["symbol", "regime"], title="AAPL trend features colored by 5-day forward return",)fig.show()
The default full matrix keeps both mirrored comparisons and visible diagonal panels. Use triangle="lower" or triangle="upper" for a more compact presentation. In research workflows, useful categorical colors include asset, volatility regime, predicted action, and train/validation/test split; useful continuous colors include forward return, realized volatility, model confidence, and sample weight.