module documentation

Matplotlib plots.

Copyright 2017-2025, Voxel51, Inc.

Class InteractiveCollection Interactive wrapper for a matplotlib collection.
Class InteractiveMatplotlibPlot Base class for interactive matplotlib plots.
Function lines Plots the given lines(s) data.
Function location_scatterplot Generates an interactive scatterplot of the given location coordinates with a map rendered in the background of the plot.
Function plot_confusion_matrix Plots a confusion matrix.
Function plot_pr_curve Plots a precision-recall (PR) curve.
Function plot_pr_curves Plots a set of per-class precision-recall (PR) curves.
Function plot_regressions Plots the given regression results.
Function plot_roc_curve Plots a receiver operating characteristic (ROC) curve.
Function scatterplot Generates an interactive scatterplot of the given points.
Variable logger Undocumented
Variable salem Undocumented
Function _ensure_salem Undocumented
Function _get_qualitative_colors Undocumented
Function _plot_lines Undocumented
Function _plot_map_background Undocumented
Function _plot_scatter Undocumented
Constant _DEFAULT_CONTINUOUS_COLORSCALE Undocumented
Constant _DEFAULT_LINE_COLOR Undocumented
Constant _DEFAULT_STYLE Undocumented
def lines(x=None, y=None, samples=None, ids=None, link_field=None, sizes=None, labels=None, colors=None, marker_size=None, title=None, xlabel=None, ylabel=None, ax=None, ax_equal=False, figsize=None, style=None, buttons=None, **kwargs): (source)

Plots the given lines(s) data.

You can attach plots generated by this method to an App session via its fiftyone.core.session.Session.plots attribute, which will automatically sync the session's view with the currently selected points in the plot. To enable this functionality, you must pass samples to this method.

You can use the sizes parameter to scale the sizes of the points.

Parameters
x:None

the x data to plot. Can be any of the following:

  • an array-like of values
  • a num_lines x n array-like or list of length num_lines of array-likes of values for multiple line traces
  • the name of a sample field or embedded.field.name of samples from which to extract values for a single line
  • the name of a frame field or frames.embedded.field.name of samples from which to extract values for per-sample line traces
  • a fiftyone.core.expressions.ViewExpression that resolves to a list (one line plot) or list of lists (multiple line plots) of numeric values to compute from samples via fiftyone.core.collections.SampleCollection.values
y:None

the y data to plot. Can be any of the following:

  • an array-like of values
  • a num_lines x n array-like or list of length num_lines of array-likes of values for multiple line traces
  • the name of a sample field or embedded.field.name of samples from which to extract values for a single line
  • the name of a frame field or frames.embedded.field.name of samples from which to extract values for per-sample line traces
  • a fiftyone.core.expressions.ViewExpression that resolves to a list (one line plot) or list of lists (multiple line plots) of numeric values to compute from samples via fiftyone.core.collections.SampleCollection.values
samples:Nonethe fiftyone.core.collections.SampleCollection whose data is being visualized
ids:Nonean array-like of IDs of same shape as y. If not provided but samples are provided, the appropriate IDs will be extracted from the samples
link_field:None

a field of samples whose data corresponds to y. Can be any of the following:

  • None, if the line data correspond to samples (single trace) or frames (multiple traces)
  • "frames", if the line data correspond to frames (multiple traces). This option exists only for consistency with other plotting methods; in practice, it will be automatically inferred whenever multiple traces are being plotted
  • the name of a fiftyone.core.labels.Label field, if the line data correspond to the labels in this field
sizes:None

data to use to scale the sizes of the points. Can be any of the following:

labels:Nonea label or list of labels for the line traces
colors:Nonea list of colors recognized by matplotlib to use for the line traces. See https://matplotlib.org/stable/tutorials/colors/colormaps.html for more information
marker_size:Nonethe marker size to use. If sizes are provided, this value is used as a reference to scale the sizes of all points
title:Nonea title for the plot
xlabel:Nonean x-axis label
ylabel:Nonea y-axis label
ax:Nonea matplotlib axis to plot in
ax_equal:Falsewhether to set axis("equal")
figsize:Nonea (width, height) for the figure, in inches
style:Nonea style to use for the plot
buttons:Nonea list of (label, icon_image, callback) tuples defining buttons to add to the plot
**kwargsoptional keyword arguments for matplotlib's plot() and scatter()
Returns

one of the following

def location_scatterplot(locations=None, samples=None, ids=None, labels=None, sizes=None, classes=None, map_type='satellite', show_scale_bar=False, api_key=None, marker_size=None, cmap=None, title=None, ax=None, ax_equal=False, figsize=None, style=None, buttons=None, **kwargs): (source)

Generates an interactive scatterplot of the given location coordinates with a map rendered in the background of the plot.

Location data is specified via the locations parameter.

You can attach plots generated by this method to an App session via its fiftyone.core.session.Session.plots attribute, which will automatically sync the session's view with the currently selected points in the plot. To enable this functionality, you must pass samples to this method.

You can use the labels parameters to define a coloring for the points, and you can use the sizes parameter to scale the sizes of the points.

Parameters
locations:None

the location data to plot. Can be any of the following:

  • None, in which case samples must have a single fiftyone.core.labels.GeoLocation field whose point attribute contains location data
  • a num_locations x 2 array-like of (longitude, latitude) coordinates
  • the name of a fiftyone.core.labels.GeoLocation field of samples with (longitude, latitude) coordinates in its point attribute
samples:Nonethe fiftyone.core.collections.SampleCollection whose data is being visualized
ids:Nonean array-like of IDs corresponding to the locations. If not provided but samples are provided, the appropriate IDs will be extracted from the samples
labels:None

data to use to color the points. Can be any of the following:

sizes:None

data to use to scale the sizes of the points. Can be any of the following:

classes:Nonea list of classes whose points to plot. Only applicable when labels contains strings
map_type:"satellite"the map type to render. Supported values are ("roadmap", "satellite", "hybrid", "terrain")
show_scale_bar:Falsewhether to render a scale bar on the plot
api_key:Nonea Google Maps API key to use
marker_size:Nonethe marker size to use. If sizes are provided, this value is used as a reference to scale the sizes of all points
cmap:Nonea colormap recognized by matplotlib
title:Nonea title for the plot
ax:Nonea matplotlib axis to plot in
ax_equal:Falsewhether to set axis("equal")
figsize:Nonea (width, height) for the figure, in inches
style:Nonea style to use for the plot
buttons:Nonea list of (label, icon_image, callback) tuples defining buttons to add to the plot
**kwargsoptional keyword arguments for matplotlib's scatter()
Returns

one of the following

def plot_confusion_matrix(confusion_matrix, labels, show_values=True, show_colorbar=True, cmap=None, title=None, xticks_rotation=45.0, values_format=None, ax=None, figsize=None): (source)

Plots a confusion matrix.

Parameters
confusion_matrixa num_true x num_preds confusion matrix
labelsa max(num_true, num_preds) array-like of class labels
show_values:Truewhether to show counts in the confusion matrix cells
show_colorbar:Truewhether to show a colorbar
cmap:Nonea colormap recognized by matplotlib
title:Nonea title for the plot
xticks_rotation:45.0a rotation for the x-tick labels. Can be numeric degrees, "vertical", "horizontal", or None
values_format:Nonea format string like ".2g" or "d" to use to format the cell counts
ax:Nonea matplotlib axis to plot in
figsize:Nonea (width, height) for the figure, in inches
Returns
a matplotlib figure
def plot_pr_curve(precision, recall, label=None, title=None, ax=None, figsize=None, style=None, **kwargs): (source)

Plots a precision-recall (PR) curve.

Parameters
precisionan array-like of precision values
recallan array-like of recall values
label:Nonea label for the curve
title:Nonea title for the plot
ax:Nonea matplotlib axis to plot in
figsize:Nonea (width, height) for the figure, in inches
style:Nonea style to use for the plot
**kwargsoptional keyword arguments for matplotlib's plot()
Returns
a matplotlib figure
def plot_pr_curves(precisions, recall, classes, title=None, ax=None, figsize=None, style=None, **kwargs): (source)

Plots a set of per-class precision-recall (PR) curves.

Parameters
precisionsa num_classes x num_recalls array-like of per-class precision values
recallan array-like of recall values
classesthe list of classes
title:Nonea title for the plot
ax:Nonea matplotlib axis to plot in
figsize:Nonea (width, height) for the figure, in inches
style:Nonea style to use for the plot
**kwargsoptional keyword arguments for matplotlib's plot()
Returns
a matplotlib figure
def plot_regressions(ytrue, ypred, samples=None, ids=None, labels=None, sizes=None, classes=None, gt_field=None, pred_field=None, best_fit_label=None, marker_size=None, cmap=None, title=None, ax=None, figsize=None, style=None, **kwargs): (source)

Plots the given regression results.

Parameters
ytruean array-like of ground truth values
ypredan array-like of predicted values
samples:Nonethe fiftyone.core.collections.SampleCollection whose data is being visualized
ids:Nonean array-like of sample or frame IDs corresponding to the regressions. If not provided but samples are provided, the appropriate IDs will be extracted from the samples
labels:None

data to use to color the points. Can be any of the following:

sizes:None

data to use to scale the sizes of the points. Can be any of the following:

classes:Nonea list of classes whose points to plot. Only applicable when labels contains strings
gt_field:Nonethe name of the ground truth field
pred_field:Nonethe name of the predictions field
best_fit_label:Nonea custom legend label for the best fit line
marker_size:Nonethe marker size to use. If sizes are provided, this value is used as a reference to scale the sizes of all points
cmap:Nonea colormap recognized by matplotlib
title:Nonea title for the plot
ax:Nonea matplotlib axis to plot in
figsize:Nonea (width, height) for the figure, in inches
style:Nonea style to use for the plot
**kwargsoptional keyword arguments for matplotlib's scatter()
Returns
a matplotlib figure
def plot_roc_curve(fpr, tpr, roc_auc=None, title=None, ax=None, figsize=None, style=None, **kwargs): (source)

Plots a receiver operating characteristic (ROC) curve.

Parameters
fpran array-like of false positive rates
tpran array-like of true positive rates
roc_auc:Nonethe area under the ROC curve
title:Nonea title for the plot
ax:Nonea matplotlib axis to plot in
figsize:Nonea (width, height) for the figure, in inches
style:Nonea style to use for the plot
**kwargsoptional keyword arguments for matplotlib's plot()
Returns
a matplotlib figure
def scatterplot(points, samples=None, ids=None, link_field=None, labels=None, sizes=None, classes=None, marker_size=None, cmap=None, title=None, ax=None, ax_equal=False, figsize=None, style=None, buttons=None, **kwargs): (source)

Generates an interactive scatterplot of the given points.

You can attach plots generated by this method to an App session via its fiftyone.core.session.Session.plots attribute, which will automatically sync the session's view with the currently selected points in the plot. To enable this functionality, you must pass samples to this method.

This method supports 2D or 3D visualizations, but interactive point selection is only available in 2D.

You can use the labels parameters to define a coloring for the points, and you can use the sizes parameter to scale the sizes of the points.

Parameters
pointsa num_points x num_dims array-like of points
samples:Nonethe fiftyone.core.collections.SampleCollection whose data is being visualized
ids:Nonean array-like of IDs corresponding to the points. If not provided but samples are provided, the appropriate IDs will be extracted from the samples
link_field:None

a field of samples whose data corresponds to points. Can be any of the following:

  • None, if the points correspond to samples
  • "frames", if the points correspond to frames
  • the name of a fiftyone.core.labels.Label field, if the points correspond to the labels in this field
labels:None

data to use to color the points. Can be any of the following:

sizes:None

data to use to scale the sizes of the points. Can be any of the following:

classes:Nonea list of classes whose points to plot. Only applicable when labels contains strings
marker_size:Nonethe marker size to use. If sizes are provided, this value is used as a reference to scale the sizes of all points
cmap:Nonea colormap recognized by matplotlib
title:Nonea title for the plot
ax:Nonea matplotlib axis to plot in
ax_equal:Falsewhether to set axis("equal")
figsize:Nonea (width, height) for the figure, in inches
style:Nonea style to use for the plot
buttons:Nonea list of (label, icon_image, callback) tuples defining buttons to add to the plot
**kwargsoptional keyword arguments for matplotlib's scatter()
Returns

one of the following

Undocumented

Undocumented

def _ensure_salem(): (source)

Undocumented

def _get_qualitative_colors(num_classes, colors=None): (source)

Undocumented

def _plot_lines(x, y, sizes=None, labels=None, colors=None, marker_size=None, xlabel=None, ylabel=None, ax=None, ax_equal=False, figsize=None, show_legend=False, **kwargs): (source)

Undocumented

def _plot_map_background(ax, locations, api_key, map_type, show_scale_bar): (source)

Undocumented

def _plot_scatter(points, labels=None, sizes=None, classes=None, categorical=False, marker_size=None, cmap=None, ax=None, ax_equal=False, figsize=None, **kwargs): (source)

Undocumented

_DEFAULT_CONTINUOUS_COLORSCALE: str = (source)

Undocumented

Value
'viridis'
_DEFAULT_LINE_COLOR: str = (source)

Undocumented

Value
'#FF6D04'
_DEFAULT_STYLE: str = (source)

Undocumented

Value
'default'