module documentation

Base plotting definitions.

Copyright 2017-2025, Voxel51, Inc.

Class InteractivePlot Base class for plots that support selection of their points.
Class Plot Base class for all plots.
Class ResponsivePlot Base class for all responsive plots that can push/pull updates to a linked object.
Class ViewPlot Base class for plots that can be automatically populated given a fiftyone.core.collections.SampleCollection instance.
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
Function _parse_backend Undocumented
def lines(x=None, y=None, samples=None, ids=None, link_field=None, sizes=None, backend='plotly', **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:

backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns

one of the following

def location_scatterplot(locations=None, samples=None, ids=None, labels=None, sizes=None, classes=None, backend='plotly', **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 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
backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns

one of the following

def plot_confusion_matrix(confusion_matrix, labels, ids=None, samples=None, eval_key=None, gt_field=None, pred_field=None, backend='plotly', **kwargs): (source)

Plots a confusion matrix.

If ids are provided and you are working in a notebook environment with the default plotly backend, this method returns an interactive fiftyone.core.plots.plotly.InteractiveHeatmap that you can attach to an App session via its fiftyone.core.session.Session.plots attribute, which will automatically sync the session's view with the currently selected cells in the confusion matrix.

Parameters
confusion_matrixa num_true x num_preds confusion matrix
labelsa max(num_true, num_preds) array-like of class labels
ids:Nonean array-like of same shape as confusion_matrix containing lists of IDs corresponding to each cell
samples:Nonethe fiftyone.core.collections.SampleCollection for which the confusion matrix was generated
eval_key:Nonethe evaluation key of the evaluation
gt_field:Nonethe name of the ground truth field
pred_field:Nonethe name of the predictions field
backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns

one of the following

def plot_pr_curve(precision, recall, thresholds=None, label=None, backend='plotly', **kwargs): (source)

Plots a precision-recall (PR) curve.

Parameters
precisionan array-like of precision values
recallan array-like of recall values
thresholds:Nonean array-like of decision thresholds
label:Nonea label for the curve
backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns

one of the following

def plot_pr_curves(precisions, recall, classes, thresholds=None, backend='plotly', **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
thresholds:Nonean num_classes x num_recalls array-like of decision thresholds
backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns

one of the following

def plot_regressions(ytrue, ypred, samples=None, ids=None, labels=None, sizes=None, classes=None, gt_field=None, pred_field=None, backend='plotly', **kwargs): (source)

Plots the given regression results.

If IDs are provided and you are working in a notebook environment with the default plotly backend, this method returns an interactive fiftyone.core.plots.plotly.InteractiveScatter that you can attach 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.

Parameters
ytruean array-like of ground truth values
ypredan array-like of predicted values
samples:Nonethe fiftyone.core.collections.SampleCollection for which the results were generated. Only used by the "plotly" backend when IDs are provided
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
backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns

one of the following

def plot_roc_curve(fpr, tpr, thresholds=None, roc_auc=None, backend='plotly', **kwargs): (source)

Plots a receiver operating characteristic (ROC) curve.

Parameters
fpran array-like of false positive rates
tpran array-like of true positive rates
thresholds:Nonean array-like of decision thresholds
roc_auc:Nonethe area under the ROC curve
backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns

one of the following

def scatterplot(points, samples=None, ids=None, link_field=None, labels=None, sizes=None, classes=None, backend='plotly', **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 linked 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:Nonean list of classes whose points to plot. Only applicable when labels contains strings
backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns

one of the following

Undocumented

def _parse_backend(backend): (source)

Undocumented