Implementation:DistrictDataLabs Yellowbrick JointPlot Visualizer
| Knowledge Sources | |
|---|---|
| Domains | Machine_Learning, Feature_Analysis, Visualization |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for bivariate joint plot analysis with marginal histograms provided by the Yellowbrick library.
Description
The JointPlot visualizer (aliased as JointPlotVisualizer) creates a scatter or hexbin plot of two variables accompanied by optional marginal histograms showing each variable's distribution. It computes and displays a correlation statistic (Pearson, Spearman, Kendall tau, or covariance) in the legend. The visualizer supports three data selection modes via the columns parameter: (1) two 1D arrays X and y plotted against each other, (2) a single column index selecting a feature to plot against the target y, or (3) two column indices selecting a pair of features from X. When histograms are enabled, additional axes are created above and to the right of the main plot using make_axes_locatable.
Usage
Use JointPlot for pairwise feature analysis or feature-to-target analysis when you want to see both the bivariate relationship and the marginal distributions simultaneously. Choose kind="scatter" for small to medium datasets and kind="hex" for larger datasets where overplotting is a concern. Histograms can be toggled with the hist parameter and set to "density" for probability density functions.
Code Reference
Source Location
- Repository: yellowbrick
- File: yellowbrick/features/jointplot.py
- Lines: JointPlot class at L48-438, quick method at L450-566
Signature
class JointPlot(FeatureVisualizer):
def __init__(
self,
ax=None,
columns=None,
correlation="pearson",
kind="scatter",
hist=True,
alpha=0.65,
joint_kws=None,
hist_kws=None,
**kwargs
):
Import
from yellowbrick.features import JointPlot
# or equivalently:
from yellowbrick.features.jointplot import JointPlotVisualizer
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| ax | matplotlib Axes | No | The axes for the main joint plot. Additional histogram axes are created automatically if hist=True.
|
| columns | int, str, [int, int], [str, str], or None | No | Column selector. None requires X and y as 1D arrays or X as 2D with 2 columns. A single index plots that column against y. Two indices plot those columns against each other.
|
| correlation | str | No | Correlation algorithm: "pearson" (default), "spearman", "covariance", or "kendalltau".
|
| kind | str | No | Plot type: "scatter" (default) or "hex".
|
| hist | bool, str, or None | No | Histogram mode: True or "frequency" for frequency histogram, "density" for probability density, False or None to disable. Default True.
|
| alpha | float | No | Transparency of scatter or hexbin points. Default 0.65.
|
| joint_kws | dict or None | No | Additional keyword arguments passed to the joint plot (scatter or hexbin). |
| hist_kws | dict or None | No | Additional keyword arguments passed to the histogram plots. |
Outputs
| Name | Type | Description |
|---|---|---|
| corr_ | float | The computed correlation value between the two plotted variables. |
| ax | matplotlib Axes | The main joint plot axes. |
| xhax | matplotlib Axes | The axes for the top marginal histogram (X-axis). Only available when hist is enabled.
|
| yhax | matplotlib Axes | The axes for the right marginal histogram (Y-axis). Only available when hist is enabled.
|
Usage Examples
Basic Usage (Feature vs. Target)
from yellowbrick.features import JointPlot
import numpy as np
# Single feature vs. target
X = np.random.randn(100)
y = X * 2.5 + np.random.randn(100) * 0.5
visualizer = JointPlot(correlation="pearson", kind="scatter", hist=True)
visualizer.fit(X, y)
visualizer.show()
Pairwise Feature Analysis
from yellowbrick.features import JointPlot
from sklearn.datasets import load_iris
import pandas as pd
data = load_iris()
X = pd.DataFrame(data.data, columns=data.feature_names)
y = data.target
visualizer = JointPlot(
columns=["sepal length (cm)", "petal length (cm)"],
correlation="spearman",
kind="scatter",
hist="density",
)
visualizer.fit(X, y)
visualizer.show()
Hexbin Mode
from yellowbrick.features import JointPlot
import numpy as np
X = np.random.randn(5000, 2)
visualizer = JointPlot(kind="hex", hist=True, alpha=0.8)
visualizer.fit(X)
visualizer.show()
Quick Method
from yellowbrick.features import joint_plot
import numpy as np
X = np.random.randn(200)
y = X * 1.5 + np.random.randn(200) * 0.3
joint_plot(X, y, correlation="pearson", kind="scatter", hist="density")