Introducing Gradio Clients


New to Gradio? Start here: Getting Started

See the Release History


import gradio as gr import pandas as pd import numpy as np simple = pd.DataFrame(np.array( [ [1, 23, "USA", "Ford Mustang"], [2, 40, "USA", "Chrysler New Yorker Brougham"], [3, 32, "Japan", "Toyota Corolla"], [4, 32, "Europe", "Mercedes Benz"], [5, 15, "USA", "AMC Matador"], [6, 35, "Europe", "BMW X5"], [7, 28, "Japan", "Honda Civic"], [8, 15, "Japan", "Honda Accord"], [9, 41, "Europe", "Peugeot 208"], ] ), columns=["Age", "Miles Per Gallon", "Origin of Car", "Name"]) with gr.Blocks() as demo: gr.ScatterPlot( value=simple, x="Age", y="Miles Per Gallon", title="Car Data", container=True, width=400, color="Origin of Car", tooltip="Name" ) demo.launch() pandas numpy


Creates a scatter plot component to display data from a pandas DataFrame (as output). As this component does not accept user input, it is rarely used as an input component.


As input component: (Rarely used) passes the data displayed in the scatter plot as an AltairPlotData dataclass, which includes the plot information as a JSON string, as well as the type of plot (in this case, "scatter").

Your function should accept one of these types:
def predict(
	value: AltairPlotData | None

As output component: Expects a pandas DataFrame containing the data to display in the scatter plot. The DataFrame should contain at least two columns, one for the x-axis (corresponding to this component's x argument) and one for the y-axis (corresponding to y).

Your function should return one of these types:
def predict(ยทยทยท) -> pd.DataFrame | dict | None
	return value




Class Interface String Shortcut Initialization



Uses default values

Event Listeners


Event listeners allow you to respond to user interactions with the UI components you've defined in a Gradio Blocks app. When a user interacts with an element, such as changing a slider value or uploading an image, a function is called.

Supported Event Listeners

The ScatterPlot component supports the following event listeners. Each event listener takes the same parameters, which are listed in the Event Parameters table below.

Listener Description

ScatterPlot.change(fn, ยทยทยท)

Triggered when the value of the Plot changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input.

ScatterPlot.clear(fn, ยทยทยท)

This listener is triggered when the user clears the Plot using the X button for the component.

Event Parameters