Visualizing data with views¶
Views display your data as plots, tables, indicators, and other visual components.
View fundamentals¶
Views are the final output of your dashboard. They transform data into visual representations that users can see and interact with.
Basic view syntax¶
Connecting views to data¶
Views get data from either sources or pipelines:
Use pipelines when you need filtering or transforms. Use sources directly for raw data.
Available view types¶
| View Type | Purpose | Best for |
|---|---|---|
hvplot |
Interactive plots | Scatter, line, bar, hist, box, etc. |
table |
Data tables | Displaying tabular data |
indicator |
Single metrics | KPIs, status values |
download |
Download buttons | Enabling data export |
hvplot_ui |
Plot with UI controls | Exploratory analysis |
altair |
Altair visualizations | Grammar of graphics plots |
plotly |
Plotly charts | 3D plots, complex interactivity |
This guide focuses on the most common types: hvplot and table.
Plot views (hvPlot)¶
The hvplot view type creates interactive plots using hvPlot.
Plot kinds¶
hvPlot supports many plot types via the kind parameter:
| Kind | Description | Use case |
|---|---|---|
scatter |
Scatter plot | Relationships between variables |
line |
Line plot | Time series, trends |
bar |
Bar chart | Comparing categories |
hist |
Histogram | Distribution of values |
box |
Box plot | Statistical distribution |
area |
Area plot | Cumulative values over time |
heatmap |
Heat map | 2D data matrices |
violin |
Violin plot | Distribution with density |
Scatter plots¶
Show relationships between two variables:
Common scatter parameters:
| Parameter | Type | Purpose |
|---|---|---|
x |
string | Column for x-axis |
y |
string | Column for y-axis |
color |
string | Column for color coding |
size |
string/int | Column for point size, or fixed size |
alpha |
float | Transparency (0-1) |
Line plots¶
Display trends over time or continuous variables:
Bar charts¶
Compare values across categories:
Histograms¶
Show distribution of values:
Box plots¶
Display statistical distribution:
views:
- type: hvplot
kind: box
y: bill_length_mm
by: species # Create box for each category
legend: false
Multiple series¶
Plot multiple columns on the same chart:
views:
- type: hvplot
kind: line
x: date
y: [revenue, expenses, profit] # Multiple y-columns
responsive: true
Plot customization¶
Common customization parameters:
| Parameter | Type | Purpose | Example |
|---|---|---|---|
title |
string | Plot title | "Sales Trends" |
xlabel |
string | X-axis label | "Date" |
ylabel |
string | Y-axis label | "Revenue ($)" |
height |
int | Plot height (pixels) | 400 |
width |
int | Plot width (pixels) | 800 |
responsive |
bool | Resize with browser | true |
legend |
string/bool | Legend position | 'top_right', false |
xlim |
tuple | X-axis range | (0, 100) |
ylim |
tuple | Y-axis range | (0, 1000) |
rot |
int | Label rotation (degrees) | 45 |
fontsize |
dict | Font sizes | {title: 16, labels: 12} |
grid |
bool | Show gridlines | true |
logx |
bool | Logarithmic x-axis | true |
logy |
bool | Logarithmic y-axis | true |
Example with many customizations:
views:
- type: hvplot
kind: scatter
x: gdp_per_capita
y: life_expectancy
color: continent
size: population
title: "Health vs Wealth"
xlabel: "GDP per Capita ($)"
ylabel: "Life Expectancy (years)"
logx: true
xlim: [100, 100000]
ylim: [40, 90]
height: 500
responsive: true
legend: 'top_left'
Table views¶
Display data in interactive tables with sorting, pagination, and filtering.
Basic table¶
Table parameters¶
| Parameter | Type | Purpose | Default |
|---|---|---|---|
show_index |
bool | Display row numbers | true |
page_size |
int | Rows per page | 20 |
pagination |
string | Pagination type | 'local' |
height |
int | Table height (pixels) | 400 |
width |
int | Table width (pixels) | None |
theme |
string | Color theme | 'default' |
disabled |
bool | Disable interactions | false |
selectable |
bool/int | Row selection | false |
Table themes¶
Available themes for table styling:
Column formatting¶
Format specific columns:
views:
- type: table
formatters:
price: {type: money, precision: 2}
date: {type: datetime, format: '%Y-%m-%d'}
percent: {type: percentage, precision: 1}
Selectable rows¶
Enable row selection:
Remote pagination¶
For large datasets, use remote pagination:
Indicator views¶
Display single metrics or KPIs.
Number indicator¶
Show a single value:
views:
- type: indicator
field: revenue # Column to display
title: "Total Revenue"
format: "${value:,.0f}" # Format as currency
Gauge indicator¶
Display value with min/max range:
views:
- type: indicator
kind: gauge
field: completion_rate
title: "Completion Rate"
min_value: 0
max_value: 100
format: "{value:.1f}%"
Download views¶
Enable data export:
See the Downloads guide for details.
Arranging views¶
Control how views appear in your dashboard.
Default arrangement¶
Views stack vertically by default:
layouts:
- title: Dashboard
views:
- type: hvplot
kind: scatter
- type: hvplot
kind: hist
- type: table
Result: Three views stacked vertically.
Grid layout¶
Use the layout parameter to create grids:
layouts:
- title: Dashboard
pipeline: my_pipeline
layout: [[0, 1], [2, 3]] # 2x2 grid
views:
- type: hvplot # View 0 (top-left)
kind: scatter
- type: hvplot # View 1 (top-right)
kind: line
- type: hvplot # View 2 (bottom-left)
kind: bar
- type: table # View 3 (bottom-right)
Custom arrangements¶
Create complex layouts:
layouts:
- title: Dashboard
layout: [[0], [1, 2], [3]] # Full-width top, two middle, full-width bottom
views:
- type: hvplot # Full width
kind: line
- type: hvplot # Half width
kind: bar
- type: hvplot # Half width
kind: hist
- type: table # Full width
Responsive sizing¶
Make views resize with browser window:
layouts:
- title: Dashboard
sizing_mode: stretch_width # or stretch_both, stretch_height
views:
- type: hvplot
responsive: true
height: 400
- type: table
height: 300
Sizing modes:
| Mode | Behavior |
|---|---|
stretch_width |
Expand to fill width |
stretch_height |
Expand to fill height |
stretch_both |
Expand to fill both dimensions |
scale_width |
Maintain aspect ratio, scale to width |
scale_height |
Maintain aspect ratio, scale to height |
fixed |
Use specified width/height only |
Tabbed layouts¶
Create tabs at the top level:
config:
layout: tabs # Use tabs instead of single page
layouts:
- title: Overview # Tab 1
views:
- type: hvplot
kind: line
- title: Detailed Analysis # Tab 2
views:
- type: table
Advanced view features¶
Linked selections¶
Link multiple plots so selecting in one highlights in others:
views:
- type: hvplot
kind: scatter
x: bill_length_mm
y: bill_depth_mm
selection_mode: lasso # Enable lasso selection
- type: hvplot
kind: hist
y: bill_length_mm
# Selection automatically links
Dynamic colormaps¶
Use dynamic colormaps for continuous values:
views:
- type: hvplot
kind: scatter
x: x
y: y
color: temperature
cmap: viridis # or: plasma, inferno, magma, coolwarm
colorbar: true
Hover tooltips¶
Customize hover information:
views:
- type: hvplot
kind: scatter
x: x
y: y
hover_cols: [name, category, details] # Show these on hover
Aggregated plots¶
Compute aggregations within the view:
Common patterns¶
Dashboard with filters and multiple plots¶
pipelines:
filtered:
source: data_source
table: data
filters:
- type: widget
field: region
- type: widget
field: year
layouts:
- title: Sales Dashboard
pipeline: filtered
layout: [[0, 1], [2]]
sizing_mode: stretch_width
views:
- type: hvplot
kind: line
x: date
y: revenue
responsive: true
height: 300
- type: hvplot
kind: bar
x: product
y: revenue
responsive: true
height: 300
- type: table
show_index: false
page_size: 15
height: 400
Comparison dashboard¶
layouts:
- title: Before vs After
layout: [[0, 1]]
views:
- type: hvplot
pipeline: before_pipeline
kind: scatter
x: x
y: y
title: "Before"
- type: hvplot
pipeline: after_pipeline
kind: scatter
x: x
y: y
title: "After"
KPI dashboard with indicators¶
pipelines:
summary:
source: data_source
table: metrics
transforms:
- type: aggregate
method: sum
layouts:
- title: KPIs
pipeline: summary
layout: [[0, 1, 2], [3]]
views:
- type: indicator
field: revenue
title: "Revenue"
format: "${value:,.0f}"
- type: indicator
field: orders
title: "Orders"
format: "{value:,}"
- type: indicator
field: conversion_rate
title: "Conversion"
format: "{value:.1f}%"
- type: hvplot
kind: line
x: date
y: revenue
Next steps¶
Now that you can visualize data:
- Variables guide - Make views dynamic with variables
- Customization guide - Build custom view types
- Deployment guide - Deploy your dashboard
For complete plot options, see the hvPlot reference.