Visualizations in Databricks notebooks

Databricks has built-in support for charts and visualizations in both Databricks SQL and in notebooks. This page describes how to work with visualizations in a Databricks notebook. For information about using visualizations in Databricks SQL, see Visualization in Databricks SQL.

To view the types of visualizations, see visualization types.

Create a new visualization

To recreate the example in this section, use the following code:

sparkDF = spark.read.csv("/databricks-datasets/bikeSharing/data-001/day.csv", header="true", inferSchema="true")
display(sparkDF)

To create a visualization, click + above a result and select Visualization. The visualization editor appears.

New visualization menu
  1. In the Visualization Type drop-down, choose a type.

    Visualization editor
  2. Select the data to appear in the visualization. The fields available depend on the selected type.

  3. Click Save.

Create a new data profile

Note

Available in Databricks Runtime 9.1 LTS and above.

Data profiles display summary statistics of an Apache Spark DataFrame, a pandas DataFrame, or a SQL table in tabular and graphic format. To create a data profile from a results cell, click + and select Data Profile.

Databricks calculates and displays the summary statistics.

Data Profile
  • Numeric and categorical features are shown in separate tables.

  • At the top of the tab, you can sort or search for features.

  • At the top of the chart column, you can choose to display a histogram (Standard) or quantiles.

  • Check expand to enlarge the charts.

  • Check log to display the charts on a log scale.

  • You can hover your cursor over the charts for more detailed information, such as the boundaries of a histogram column and the number of rows in it, or the quantile value.

You can also generate data profiles programmatically; see summarize command (dbutils.data.summarize).

Work with visualizations and data profiles

Note

Data profiles are available in Databricks Runtime 9.1 LTS and above.

Rename, duplicate, or remove a visualization or data profile

To rename, duplicate, or remove a visualization or data profile, click the downward pointing arrow at the right of the tab name. You can also create a dashboard from the menu.

Note

If the cell contains a data profile, the associated visualization and data profile can only be added to a notebook dashboard. For cellswith only visualizations, you’ll see an additional Add to dashboard menu item in the drop down. See Add a visualization to a dashboard.

Notebook data profile drop down menu

You can also change the name by clicking directly on it and editing the name in place.

Edit a visualization

Click Edit visualization button beneath the visualization to open the visualization editor. When you have finished making changes, click Save.

Edit colors

You can customize a visualization’s colors when you create the visualization or by editing it.

  1. Create or edit a visualization.

  2. Click Colors.

  3. To modify a color, click the square and select the new color by doing one of the following:

    • Click it in the color selector.

    • Enter a hex value.

  4. Click anywhere outside the color selector to close it.

  5. Click Save in the Visualization Editor to save the changes.

Series selection

To select a specific series to analyze on a chart, use the following commands:

  • Click on a single legend item to select that series

  • Cmd/Ctrl + click on a legend item to select or deselect multiple series

Series selection

Sorted tooltips

Use tooltips on line charts and unstacked bar charts, ordered by magnitude, for easier analysis.

sorted tooltips

Zoom

For data-dense charts, zooming in on individual data points can be helpful to investigate details and to crop outliers. To zoom in a chart, click and drag on the canvas. To clear the zoom, hover over the canvas and click the Clear zoom button in the upper right corner of the visualization.

zoom in to see details

Download a visualization as a PNG file

To dowload a visualization as a PNG file, hover over the canvas and click the download icon in the upper-right corner.

Click download to export the visualization as a PNG file

A png file is downloaded to your device.

Add a visualization to a dashboard

  1. Click the downward pointing arrow at the right of the tab name.

  2. Select Add to dashboard. A list of available dashboard views appears, along with a menu option Add to new dashboard.

  3. Select a dashboard or select Add to new dashboard. The dashboard appears, including the newly added visualization.

Legacy visualizations

The latest version of chart visualizations is on by default. The settings in this section describe legacy visualization that you might encounter when working with an older chart, or if you have the latest version turned off.

Visualization tools

If you hover over the top right of a chart, a Plotly toolbar appears where you can perform operations such as select, zoom, and pan.

Notebook visualization editor toolbar

Download a visualization

To download a visualization in .png format, click the camera icon camera iconin the notebook cell or in the visualization editor.

  • In a result cell, the camera icon appears at the upper right when you move the cursor over the cell.

    camera in notebook cell
  • In the visualization editor, the camera icon appears when you move the cursor over the chart. See Visualization tools.

Temporarily hide or show a series

To hide a series in a visualization, click the series in the legend. To show the series again, click it again in the legend.

To show only a single series, double-click the series in the legend. To show other series, click each one.