Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt

Use this file to discover all available pages before exploring further.

The BarPlot component creates interactive bar charts from pandas DataFrames using Gradio’s native plotting.

Basic usage

import gradio as gr
import pandas as pd

df = pd.DataFrame({
    "category": ["A", "B", "C"],
    "value": [10, 25, 15]
})

gr.BarPlot(
    value=df,
    x="category",
    y="value"
)

Constructor

value
pd.DataFrame | Callable | None
default:"None"
Pandas DataFrame containing the data
x
str | None
default:"None"
Column name for x-axis (can be numeric, datetime, or string)
y
str | None
default:"None"
Column name for y-axis (must be numeric)
color
str | None
default:"None"
Column name for color grouping (must be string/category)
title
str | None
default:"None"
Chart title
x_title
str | None
default:"None"
X-axis title (defaults to column name)
y_title
str | None
default:"None"
Y-axis title (defaults to column name)
color_map
dict[str, str] | None
default:"None"
Mapping of series names to colors (e.g., {"A": "red", "B": "#00FF00"})
height
int | None
default:"None"
Plot height in pixels
y_lim
list[float | None]
default:"None"
Y-axis limits as [min, max]. Use None to auto-scale one end

Events

  • select - Triggered when bar is selected
  • double_click - Triggered on double click

Example

import gradio as gr
import pandas as pd

def create_sales_chart():
    df = pd.DataFrame({
        "Product": ["A", "B", "C", "D"],
        "Sales": [120, 250, 180, 90],
        "Region": ["North", "North", "South", "South"]
    })
    return df

with gr.Blocks() as demo:
    plot = gr.BarPlot(
        value=create_sales_chart(),
        x="Product",
        y="Sales",
        color="Region",
        title="Sales by Product",
        color_map={"North": "#FF6B6B", "South": "#4ECDC4"},
        height=400
    )
    
demo.launch()

Build docs developers (and LLMs) love