text
stringlengths
0
2k
heading1
stringlengths
3
79
source_page_url
stringclasses
190 values
source_page_title
stringclasses
190 values
Once you have connected to a Gradio app, you can view the APIs that are available to you by calling the `Client.view_api()` method. For the Whisper Space, we see the following: ```bash Client.predict() Usage Info --------------------------- Named API endpoints: 1 - predict(audio, api_name="/predict") -> output P...
Inspecting the API endpoints
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
As an alternative to running the `.view_api()` method, you can click on the "Use via API" link in the footer of the Gradio app, which shows us the same information, along with example usage. ![](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/gradio-guides/view-api.png) The View API pag...
The "View API" Page
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
The simplest way to make a prediction is simply to call the `.predict()` function with the appropriate arguments: ```python from gradio_client import Client client = Client("abidlabs/en2fr") client.predict("Hello", api_name='/predict') >> Bonjour ``` If there are multiple parameters, then you should pass them as se...
Making a prediction
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
```python from gradio_client import Client, handle_file client = Client("abidlabs/whisper") client.predict( audio=handle_file("https://audio-samples.github.io/samples/mp3/blizzard_unconditional/sample-0.mp3") ) >> "My thought I have nobody by a beauty and will as you poured. Mr. Rochester is serve in that so don'...
Making a prediction
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
One should note that `.predict()` is a _blocking_ operation as it waits for the operation to complete before returning the prediction. In many cases, you may be better off letting the job run in the background until you need the results of the prediction. You can do this by creating a `Job` instance using the `.submit...
Running jobs asynchronously
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
Alternatively, one can add one or more callbacks to perform actions after the job has completed running, like this: ```python from gradio_client import Client def print_result(x): print("The translated result is: {x}") client = Client(space="abidlabs/en2fr") job = client.submit("Hello", api_name="/predict", res...
Adding callbacks
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
The `Job` object also allows you to get the status of the running job by calling the `.status()` method. This returns a `StatusUpdate` object with the following attributes: `code` (the status code, one of a set of defined strings representing the status. See the `utils.Status` class), `rank` (the current position of th...
Status
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
The `Job` class also has a `.cancel()` instance method that cancels jobs that have been queued but not started. For example, if you run: ```py client = Client("abidlabs/whisper") job1 = client.submit(handle_file("audio_sample1.wav")) job2 = client.submit(handle_file("audio_sample2.wav")) job1.cancel() will return Fal...
Cancelling Jobs
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
Some Gradio API endpoints do not return a single value, rather they return a series of values. You can get the series of values that have been returned at any time from such a generator endpoint by running `job.outputs()`: ```py from gradio_client import Client client = Client(src="gradio/count_generator") job = clie...
Generator Endpoints
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
Gradio demos can include [session state](https://www.gradio.app/guides/state-in-blocks), which provides a way for demos to persist information from user interactions within a page session. For example, consider the following demo, which maintains a list of words that a user has submitted in a `gr.State` component. Whe...
Demos with Session State
https://gradio.app/guides/getting-started-with-the-python-client
Gradio Clients And Lite - Getting Started With The Python Client Guide
Install the @gradio/client package to interact with Gradio APIs using Node.js version >=18.0.0 or in browser-based projects. Use npm or any compatible package manager: ```bash npm i @gradio/client ``` This command adds @gradio/client to your project dependencies, allowing you to import it in your JavaScript or TypeSc...
Installation via npm
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
For quick addition to your web project, you can use the jsDelivr CDN to load the latest version of @gradio/client directly into your HTML: ```html <script type="module"> import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js"; ... </script> ``` Be sure to add this to the `<head>` of y...
Installation via CDN
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
Start by connecting instantiating a `client` instance and connecting it to a Gradio app that is running on Hugging Face Spaces or generally anywhere on the web.
Connecting to a running Gradio App
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
```js import { Client } from "@gradio/client"; const app = await Client.connect("abidlabs/en2fr"); // a Space that translates from English to French ``` You can also connect to private Spaces by passing in your HF token with the `token` property of the options parameter. You can get your HF token here: https://huggin...
Connecting to a Hugging Face Space
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
While you can use any public Space as an API, you may get rate limited by Hugging Face if you make too many requests. For unlimited usage of a Space, simply duplicate the Space to create a private Space, and then use it to make as many requests as you'd like! You'll need to pass in your [Hugging Face token](https://hug...
Duplicating a Space for private use
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
If your app is running somewhere else, just provide the full URL instead, including the "http://" or "https://". Here's an example of making predictions to a Gradio app that is running on a share URL: ```js import { Client } from "@gradio/client"; const app = Client.connect("https://bec81a83-5b5c-471e.gradio.live"); ...
Connecting a general Gradio app
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
If the Gradio application you are connecting to [requires a username and password](/guides/sharing-your-appauthentication), then provide them as a tuple to the `auth` argument of the `Client` class: ```js import { Client } from "@gradio/client"; Client.connect( space_name, { auth: [username, password] } ) ```
Connecting to a Gradio app with auth
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
Once you have connected to a Gradio app, you can view the APIs that are available to you by calling the `Client`'s `view_api` method. For the Whisper Space, we can do this: ```js import { Client } from "@gradio/client"; const app = await Client.connect("abidlabs/whisper"); const app_info = await app.view_api(); co...
Inspecting the API endpoints
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
As an alternative to running the `.view_api()` method, you can click on the "Use via API" link in the footer of the Gradio app, which shows us the same information, along with example usage. ![](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/gradio-guides/view-api.png) The View API pag...
The "View API" Page
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
The simplest way to make a prediction is simply to call the `.predict()` method with the appropriate arguments: ```js import { Client } from "@gradio/client"; const app = await Client.connect("abidlabs/en2fr"); const result = await app.predict("/predict", ["Hello"]); ``` If there are multiple parameters, then you sh...
Making a prediction
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
If the API you are working with can return results over time, or you wish to access information about the status of a job, you can use the iterable interface for more flexibility. This is especially useful for iterative endpoints or generator endpoints that will produce a series of values over time as discrete response...
Using events
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
The event interface also allows you to get the status of the running job by instantiating the client with the `events` options passing `status` and `data` as an array: ```ts import { Client } from "@gradio/client"; const app = await Client.connect("abidlabs/en2fr", { events: ["status", "data"] }); ``` This ensures...
Status
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
The job instance also has a `.cancel()` method that cancels jobs that have been queued but not started. For example, if you run: ```js import { Client } from "@gradio/client"; const app = await Client.connect("abidlabs/en2fr"); const job_one = app.submit("/predict", ["Hello"]); const job_two = app.submit("/predict", ...
Cancelling Jobs
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
Some Gradio API endpoints do not return a single value, rather they return a series of values. You can listen for these values in real time using the iterable interface: ```js import { Client } from "@gradio/client"; const app = await Client.connect("gradio/count_generator"); const job = app.submit(0, [9]); for awai...
Generator Endpoints
https://gradio.app/guides/getting-started-with-the-js-client
Gradio Clients And Lite - Getting Started With The Js Client Guide
What are agents? A [LangChain agent](https://docs.langchain.com/docs/components/agents/agent) is a Large Language Model (LLM) that takes user input and reports an output based on using one of many tools at its disposal. What is Gradio? [Gradio](https://github.com/gradio-app/gradio) is the defacto standard framework ...
Some background
https://gradio.app/guides/gradio-and-llm-agents
Gradio Clients And Lite - Gradio And Llm Agents Guide
To get started with `gradio_tools`, all you need to do is import and initialize your tools and pass them to the langchain agent! In the following example, we import the `StableDiffusionPromptGeneratorTool` to create a good prompt for stable diffusion, the `StableDiffusionTool` to create an image with our improved prom...
gradio_tools - An end-to-end example
https://gradio.app/guides/gradio-and-llm-agents
Gradio Clients And Lite - Gradio And Llm Agents Guide
that come with `gradio_tools`. Please see this [doc](https://github.com/freddyaboulton/gradio-toolsgradio-tools-gradio--llm-agents) for a complete list of the tools that come with `gradio_tools`. If you would like to use a tool that's not currently in `gradio_tools`, it is very easy to add your own. That's what the nex...
gradio_tools - An end-to-end example
https://gradio.app/guides/gradio-and-llm-agents
Gradio Clients And Lite - Gradio And Llm Agents Guide
The core abstraction is the `GradioTool`, which lets you define a new tool for your LLM as long as you implement a standard interface: ```python class GradioTool(BaseTool): def __init__(self, name: str, description: str, src: str) -> None: @abstractmethod def create_job(self, query: str) -> Job: ...
gradio_tools - creating your own tool
https://gradio.app/guides/gradio-and-llm-agents
Gradio Clients And Lite - Gradio And Llm Agents Guide
lf, gr)` and `_block_output(self, gr)` methods of the tool. The `gr` variable is the gradio module (the result of `import gradio as gr`). It will be automatically imported by the `GradiTool` parent class and passed to the `_block_input` and `_block_output` methods. And that's it! Once you have created your tool, o...
gradio_tools - creating your own tool
https://gradio.app/guides/gradio-and-llm-agents
Gradio Clients And Lite - Gradio And Llm Agents Guide
Here is the code for the StableDiffusion tool as an example: ```python from gradio_tool import GradioTool import os class StableDiffusionTool(GradioTool): """Tool for calling stable diffusion from llm""" def __init__( self, name="StableDiffusion", description=( "An image g...
Example tool - Stable Diffusion
https://gradio.app/guides/gradio-and-llm-agents
Gradio Clients And Lite - Gradio And Llm Agents Guide
You now know how to extend the abilities of your LLM with the 1000s of gradio spaces running in the wild! Again, we welcome any contributions to the [gradio_tools](https://github.com/freddyaboulton/gradio-tools) library. We're excited to see the tools you all build!
Conclusion
https://gradio.app/guides/gradio-and-llm-agents
Gradio Clients And Lite - Gradio And Llm Agents Guide
Let's start with what seems like the most complex bit -- using machine learning to remove the music from a video. Luckily for us, there's an existing Space we can use to make this process easier: [https://huggingface.co/spaces/abidlabs/music-separation](https://huggingface.co/spaces/abidlabs/music-separation). This Sp...
Step 1: Write the Video Processing Function
https://gradio.app/guides/fastapi-app-with-the-gradio-client
Gradio Clients And Lite - Fastapi App With The Gradio Client Guide
f heavy lifting when it comes to working with audio and video files. The most common way to use `ffmpeg` is through the command line, which we'll call via Python's `subprocess` module: Our video processing workflow will consist of three steps: 1. First, we start by taking in a video filepath and extracting the audio ...
Step 1: Write the Video Processing Function
https://gradio.app/guides/fastapi-app-with-the-gradio-client
Gradio Clients And Lite - Fastapi App With The Gradio Client Guide
Next up, we'll create a simple FastAPI app. If you haven't used FastAPI before, check out [the great FastAPI docs](https://fastapi.tiangolo.com/). Otherwise, this basic template, which we add to `main.py`, will look pretty familiar: ```python import os from fastapi import FastAPI, File, UploadFile, Request from fastap...
Step 2: Create a FastAPI app (Backend Routes)
https://gradio.app/guides/fastapi-app-with-the-gradio-client
Gradio Clients And Lite - Fastapi App With The Gradio Client Guide
Finally, we create the frontend of our web application. First, we create a folder called `templates` in the same directory as `main.py`. We then create a template, `home.html` inside the `templates` folder. Here is the resulting file structure: ```csv ├── main.py ├── templates │ └── home.html ``` Write the followin...
Step 3: Create a FastAPI app (Frontend Template)
https://gradio.app/guides/fastapi-app-with-the-gradio-client
Gradio Clients And Lite - Fastapi App With The Gradio Client Guide
class="upload-btn">Choose video file&lt;/label> &lt;input type="file" name="video" id="video-upload"> &lt;span class="file-name">&lt;/span> &lt;button type="submit" class="upload-btn">Upload&lt;/button> &lt;/form> &lt;script> // Display selected file name in the form const fileUpload = document.getElementById("video-up...
Step 3: Create a FastAPI app (Frontend Template)
https://gradio.app/guides/fastapi-app-with-the-gradio-client
Gradio Clients And Lite - Fastapi App With The Gradio Client Guide
Finally, we are ready to run our FastAPI app, powered by the Gradio Python Client! Open up a terminal and navigate to the directory containing `main.py`. Then run the following command in the terminal: ```bash $ uvicorn main:app ``` You should see an output that looks like this: ```csv Loaded as API: https://abidla...
Step 4: Run your FastAPI app
https://gradio.app/guides/fastapi-app-with-the-gradio-client
Gradio Clients And Lite - Fastapi App With The Gradio Client Guide
You generally don't need to install cURL, as it comes pre-installed on many operating systems. Run: ```bash curl --version ``` to confirm that `curl` is installed. If it is not already installed, you can install it by visiting https://curl.se/download.html.
Installation
https://gradio.app/guides/querying-gradio-apps-with-curl
Gradio Clients And Lite - Querying Gradio Apps With Curl Guide
To query a Gradio app, you'll need its full URL. This is usually just the URL that the Gradio app is hosted on, for example: https://bec81a83-5b5c-471e.gradio.live **Hugging Face Spaces** However, if you are querying a Gradio on Hugging Face Spaces, you will need to use the URL of the embedded Gradio app, not the UR...
Step 0: Get the URL for your Gradio App
https://gradio.app/guides/querying-gradio-apps-with-curl
Gradio Clients And Lite - Querying Gradio Apps With Curl Guide
The first of the two `curl` requests is `POST` request that submits the input payload to the Gradio app. The syntax of the `POST` request is as follows: ```bash $ curl -X POST $URL/call/$API_NAME -H "Content-Type: application/json" -d '{ "data": $PAYLOAD }' ``` Here: * `$URL` is the URL of the Gradio app as obta...
Step 1: Make a Prediction (POST)
https://gradio.app/guides/querying-gradio-apps-with-curl
Gradio Clients And Lite - Querying Gradio Apps With Curl Guide
king a request to a private Space, you will need to pass in a [Hugging Face token](https://huggingface.co/settings/tokens) that has read access to the Space. The request will look like this: ```bash $ curl -X POST https://private-space.hf.space/call/predict -H "Content-Type: application/json" -H "Authorization: Bearer...
Step 1: Make a Prediction (POST)
https://gradio.app/guides/querying-gradio-apps-with-curl
Gradio Clients And Lite - Querying Gradio Apps With Curl Guide
ient?"], "session_hash": "newsequence5678" }' ```
Step 1: Make a Prediction (POST)
https://gradio.app/guides/querying-gradio-apps-with-curl
Gradio Clients And Lite - Querying Gradio Apps With Curl Guide
Once you have received the `EVENT_ID` corresponding to your prediction, you can stream the results. Gradio stores these results in a least-recently-used cache in the Gradio app. By default, the cache can store 2,000 results (across all users and endpoints of the app). To stream the results for your prediction, make ...
Step 2: GET the result
https://gradio.app/guides/querying-gradio-apps-with-curl
Gradio Clients And Lite - Querying Gradio Apps With Curl Guide
```bash event: generating data: ["Hello, w!"] event: generating data: ["Hello, wo!"] event: generating data: ["Hello, wor!"] event: generating data: ["Hello, worl!"] event: generating data: ["Hello, world!"] event: complete data: ["Hello, world!"] ``` **File Example** If your Gradio app returns a file, the file will ...
Step 2: GET the result
https://gradio.app/guides/querying-gradio-apps-with-curl
Gradio Clients And Lite - Querying Gradio Apps With Curl Guide
What if your Gradio application has [authentication enabled](/guides/sharing-your-appauthentication)? In that case, you'll need to make an additional `POST` request with cURL to authenticate yourself before you make any queries. Here are the complete steps: First, login with a `POST` request supplying a valid username...
Authentication
https://gradio.app/guides/querying-gradio-apps-with-curl
Gradio Clients And Lite - Querying Gradio Apps With Curl Guide
Use `gradio.Server` instead of `gr.Blocks` when any of the following apply: - You want a **completely custom (potentially vibe-coded) UI** (your own HTML, React, Svelte, etc.) powered by Gradio's backend - You want **full FastAPI control** (custom GET/POST routes, middleware, dependency injection) alongside Gradio API...
When to use `gradio.Server`
https://gradio.app/guides/server-mode
Gradio Clients And Lite - Server Mode Guide
`gradio.Server` is included in the main Gradio package. If you want MCP support, install the extra: ```bash pip install "gradio[mcp]" ```
Installation
https://gradio.app/guides/server-mode
Gradio Clients And Lite - Server Mode Guide
Here's the simplest possible Server mode app — a single API endpoint with no UI: ```python from gradio import Server app = Server() @app.api(name="hello") def hello(name: str) -> str: return f"Hello, {name}!" app.launch() ``` That's it. When you run this script, you get: - A Gradio API endpoint at `/gradio_ap...
A Minimal Example
https://gradio.app/guides/server-mode
Gradio Clients And Lite - Server Mode Guide
Since `gradio.Server` inherits from FastAPI, you can add any route directly: ```python from gradio import Server from fastapi.responses import HTMLResponse app = Server() @app.api(name="hello") def hello(name: str) -> str: return f"Hello, {name}!" @app.get("/", response_class=HTMLResponse) async def homepage():...
Custom Routes
https://gradio.app/guides/server-mode
Gradio Clients And Lite - Server Mode Guide
To expose your API endpoints as MCP tools, add the `@app.mcp.tool()` decorator and pass `mcp_server=True` to `launch()`: ```python from gradio import Server app = Server() @app.mcp.tool(name="hello") @app.api(name="hello") def hello(name: str) -> str: """Greet someone by name.""" return f"Hello, {name}!" ap...
MCP Tools
https://gradio.app/guides/server-mode
Gradio Clients And Lite - Server Mode Guide
This example combines everything: custom HTML served at `/`, Gradio API endpoints with concurrency limits, MCP tools, and a custom REST endpoint, and two connected via [the Gradio JavaScript client](/guides/getting-started-with-the-js-client). $code_server_app Run it with: ```bash python run.py ``` Then open `http:...
A Complete Example with the JavaScript Client
https://gradio.app/guides/server-mode
Gradio Clients And Lite - Server Mode Guide
`app.api()` supports all of the same concurrency and streaming options as `gr.api()`: ```python @app.api(name="generate", concurrency_limit=2, stream_every=0.5) async def generate(prompt: str): for token in model.generate(prompt): yield token ``` Generator functions automatically stream results via SSE, j...
Concurrency and Streaming
https://gradio.app/guides/server-mode
Gradio Clients And Lite - Server Mode Guide
**Prerequisite**: Gradio requires [Python 3.10 or higher](https://www.python.org/downloads/). We recommend installing Gradio using `pip`, which is included by default in Python. Run this in your terminal or command prompt: ```bash pip install --upgrade gradio ``` Tip: It is best to install Gradio in a virtual envi...
Installation
https://gradio.app/guides/quickstart
Getting Started - Quickstart Guide
You can run Gradio in your favorite code editor, Jupyter notebook, Google Colab, or anywhere else you write Python. Let's write your first Gradio app: $code_hello_world_4 Tip: We shorten the imported name from <code>gradio</code> to <code>gr</code>. This is a widely adopted convention for better readability of code...
Building Your First Demo
https://gradio.app/guides/quickstart
Getting Started - Quickstart Guide
turn one or more outputs. The `Interface` class has three core arguments: - `fn`: the function to wrap a user interface (UI) around - `inputs`: the Gradio component(s) to use for the input. The number of components should match the number of arguments in your function. - `outputs`: the Gradio component(s) to use for...
Building Your First Demo
https://gradio.app/guides/quickstart
Getting Started - Quickstart Guide
What good is a beautiful demo if you can't share it? Gradio lets you easily share a machine learning demo without having to worry about the hassle of hosting on a web server. Simply set `share=True` in `launch()`, and a publicly accessible URL will be created for your demo. Let's revisit our example demo, but change t...
Sharing Your Demo
https://gradio.app/guides/quickstart
Getting Started - Quickstart Guide
So far, we've been discussing the `Interface` class, which is a high-level class that lets you build demos quickly with Gradio. But what else does Gradio include? Custom Demos with `gr.Blocks` Gradio offers a low-level approach for designing web apps with more customizable layouts and data flows with the `gr.Blocks` ...
An Overview of Gradio
https://gradio.app/guides/quickstart
Getting Started - Quickstart Guide
.app/guides/getting-started-with-the-python-client) (`gradio_client`): query any Gradio app programmatically in Python. * [Gradio JavaScript Client](https://www.gradio.app/guides/getting-started-with-the-js-client) (`@gradio/client`): query any Gradio app programmatically in JavaScript. * [Hugging Face Spaces](https://...
An Overview of Gradio
https://gradio.app/guides/quickstart
Getting Started - Quickstart Guide
Keep learning about Gradio sequentially using the Gradio Guides, which include explanations as well as example code and embedded interactive demos. Next up: [let's dive deeper into the Interface class](https://www.gradio.app/guides/the-interface-class). Or, if you already know the basics and are looking for something ...
What's Next?
https://gradio.app/guides/quickstart
Getting Started - Quickstart Guide
```python from sqlalchemy import create_engine import pandas as pd engine = create_engine('sqlite:///your_database.db') with gr.Blocks() as demo: gr.LinePlot(pd.read_sql_query("SELECT time, price from flight_info;", engine), x="time", y="price") ``` Let's see a a more interactive plot involving filters that modi...
SQLite
https://gradio.app/guides/connecting-to-a-database
Data Science And Plots - Connecting To A Database Guide
If you're using a different database format, all you have to do is swap out the engine, e.g. ```python engine = create_engine('postgresql://username:password@host:port/database_name') ``` ```python engine = create_engine('mysql://username:password@host:port/database_name') ``` ```python engine = create_engine('oracl...
Postgres, mySQL, and other databases
https://gradio.app/guides/connecting-to-a-database
Data Science And Plots - Connecting To A Database Guide
Plots accept a pandas Dataframe as their value. The plot also takes `x` and `y` which represent the names of the columns that represent the x and y axes respectively. Here's a simple example: $code_plot_guide_line $demo_plot_guide_line All plots have the same API, so you could swap this out with a `gr.ScatterPlot`: ...
Creating a Plot with a pd.Dataframe
https://gradio.app/guides/creating-plots
Data Science And Plots - Creating Plots Guide
You can break out your plot into series using the `color` argument. $code_plot_guide_series_nominal $demo_plot_guide_series_nominal If you wish to assign series specific colors, use the `color_map` arg, e.g. `gr.ScatterPlot(..., color_map={'white': 'FF9988', 'asian': '88EEAA', 'black': '333388'})` The color column c...
Breaking out Series by Color
https://gradio.app/guides/creating-plots
Data Science And Plots - Creating Plots Guide
You can aggregate values into groups using the `x_bin` and `y_aggregate` arguments. If your x-axis is numeric, providing an `x_bin` will create a histogram-style binning: $code_plot_guide_aggregate_quantitative $demo_plot_guide_aggregate_quantitative If your x-axis is a string type instead, they will act as the categ...
Aggregating Values
https://gradio.app/guides/creating-plots
Data Science And Plots - Creating Plots Guide
You can use the `.select` listener to select regions of a plot. Click and drag on the plot below to select part of the plot. $code_plot_guide_selection $demo_plot_guide_selection You can combine this and the `.double_click` listener to create some zoom in/out effects by changing `x_lim` which sets the bounds of the x...
Selecting Regions
https://gradio.app/guides/creating-plots
Data Science And Plots - Creating Plots Guide
Take a look how you can have an interactive dashboard where the plots are functions of other Components. $code_plot_guide_interactive $demo_plot_guide_interactive It's that simple to filter and control the data presented in your visualization!
Making an Interactive Dashboard
https://gradio.app/guides/creating-plots
Data Science And Plots - Creating Plots Guide
Use any of the standard Gradio form components to filter your data. You can do this via event listeners or function-as-value syntax. Let's look at the event listener approach first: $code_plot_guide_filters_events $demo_plot_guide_filters_events And this would be the function-as-value approach for the same demo. $co...
Filters
https://gradio.app/guides/filters-tables-and-stats
Data Science And Plots - Filters Tables And Stats Guide
Add `gr.DataFrame` and `gr.Label` to your dashboard for some hard numbers. $code_plot_guide_tables_stats $demo_plot_guide_tables_stats
Tables and Stats
https://gradio.app/guides/filters-tables-and-stats
Data Science And Plots - Filters Tables And Stats Guide
Time plots need a datetime column on the x-axis. Here's a simple example with some flight data: $code_plot_guide_temporal $demo_plot_guide_temporal
Creating a Plot with a pd.Dataframe
https://gradio.app/guides/time-plots
Data Science And Plots - Time Plots Guide
You may wish to bin data by time buckets. Use `x_bin` to do so, using a string suffix with "s", "m", "h" or "d", such as "15m" or "1d". $code_plot_guide_aggregate_temporal $demo_plot_guide_aggregate_temporal
Aggregating by Time
https://gradio.app/guides/time-plots
Data Science And Plots - Time Plots Guide
You can use `gr.DateTime` to accept input datetime data. This works well with plots for defining the x-axis range for the data. $code_plot_guide_datetime $demo_plot_guide_datetime Note how `gr.DateTime` can accept a full datetime string, or a shorthand using `now - [0-9]+[smhd]` format to refer to a past time. You w...
DateTime Components
https://gradio.app/guides/time-plots
Data Science And Plots - Time Plots Guide
In many cases, you're working with live, realtime date, not a static dataframe. In this case, you'd update the plot regularly with a `gr.Timer()`. Assuming there's a `get_data` method that gets the latest dataframe: ```python with gr.Blocks() as demo: timer = gr.Timer(5) plot1 = gr.BarPlot(x="time", y="price")...
RealTime Data
https://gradio.app/guides/time-plots
Data Science And Plots - Time Plots Guide