# Python Interactive Charting Libraries Compared: Plotly, Bokeh, Altair, hvPlot, pyecharts

> Compare Python interactive charting libraries on one chart: Plotly Express, Altair, Bokeh, hvPlot, and pyecharts. See the code for each, the output, HTML file sizes, and which to choose.

Source: https://www.pythoncharts.com/python/python-interactive-charting-libraries-compared/ | Published: 2026-11-25 | Author: Alex Scott | Category: Python | Tags: plotly, bokeh, altair, hvplot, pyecharts, interactive charts, comparison

For most Python projects, **Plotly Express** is the default pick for interactive charts: it has the widest range of chart types, a short API, and good Jupyter and Streamlit support. **Altair** is the better fit if you like a declarative grammar, **Bokeh** if you need a lot of control or server-side callbacks, **hvPlot** if you want `df.plot`-style one-liners on top of Bokeh, and **pyecharts** if you want Apache ECharts' look and chart types. This post draws the same scatter chart in each so you can compare the code and the results. Versions used: Plotly 6.9.0, Altair 6.2.2, Bokeh 3.10.2, hvPlot 0.13.0, pyecharts 2.1.0.

## Quick Example

A scatter chart of 240 simulated days of bike rentals against temperature, colored by season, in Plotly Express. It runs on its own and writes a standalone HTML file you can open or share.

```python
import numpy as np
import pandas as pd
import plotly.express as px

rng = np.random.default_rng(12)
seasons = ["Winter", "Spring", "Summer", "Autumn"]
base_temp = {"Winter": 4, "Spring": 14, "Summer": 25, "Autumn": 13}
season = rng.choice(seasons, 240)
temp = np.array([base_temp[s] for s in season]) + rng.normal(0, 3.5, 240)
rentals = (300 + 55 * temp - 0.9 * temp**2 + rng.normal(0, 120, 240)).clip(50).round()
df = pd.DataFrame({"temp": temp.round(1), "rentals": rentals, "season": season})
colors = {"Winter": "#4c6ef5", "Spring": "#40c057", "Summer": "#f59f00", "Autumn": "#e8590c"}

fig = px.scatter(df, x="temp", y="rentals", color="season", color_discrete_map=colors,
                 category_orders={"season": seasons},
                 labels={"temp": "Temperature (°C)", "rentals": "Bike rentals"})
fig.write_html("plotly.html", include_plotlyjs="cdn")
```

Rentals rise with temperature (correlation 0.86 in this data), and summer days sit at the top right at an average of about 1,100 rentals, against about 520 in winter. The other blocks reuse `df`, `colors`, and `seasons`.

## The Same Chart in Each Library

### Plotly Express

The Quick Example above is the whole thing: one function call, hover tooltips, zoom, pan, and legend toggling come built in. Plotly has by far the broadest chart catalog here, including maps, 3D, financial charts, and Sankey diagrams. See [how to customize hover tooltips](https://www.pythoncharts.com/plotly/plotly-customize-hover-tooltips/) for the next step.

### Altair

```python
import altair as alt

chart = alt.Chart(df).mark_circle(size=60, opacity=0.8).encode(
    x=alt.X("temp", title="Temperature (°C)"),
    y=alt.Y("rentals", title="Bike rentals"),
    color=alt.Color("season", scale=alt.Scale(domain=seasons, range=list(colors.values()))),
    tooltip=["temp", "rentals", "season"],
).properties(width=480, height=320).interactive()
chart.save("altair.html")
```

Altair describes the chart as a mapping from columns to visual channels (`x`, `y`, `color`) and compiles it to Vega-Lite. Tooltips are opt-in through `tooltip=`, and `.interactive()` adds zoom and pan. It is the most readable option once you know the grammar, and it makes linked selections across charts simple. It is smaller on chart types than Plotly. See [An Introduction to Altair](https://www.pythoncharts.com/altair/intro-to-altair/).

### Bokeh

```python
from bokeh.embed import file_html
from bokeh.models import HoverTool
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.transform import factor_cmap

p = figure(width=640, height=420, x_axis_label="Temperature (°C)",
           y_axis_label="Bike rentals", tools="pan,wheel_zoom,box_zoom,reset")
p.scatter("temp", "rentals", source=df, size=8, alpha=0.8, legend_field="season",
          color=factor_cmap("season", list(colors.values()), seasons))
p.add_tools(HoverTool(tooltips=[("season", "@season"), ("temp", "@temp"), ("rentals", "@rentals")]))
with open("bokeh.html", "w") as f:
    f.write(file_html(p, CDN, "bokeh"))
```

Bokeh is the most explicit: you build a `figure`, add glyphs, and add tools yourself. That's more code, but you get control over every element, plus widgets and a server (`bokeh serve`) for Python callbacks, so a slider can recompute data in Python rather than JavaScript.

### hvPlot

```python
import hvplot.pandas  # adds .hvplot to DataFrames
import holoviews as hv

hv_plot = df.hvplot.scatter(x="temp", y="rentals", by="season", hover_cols=["season"],
                            color=[colors[s] for s in df["season"].unique()],
                            xlabel="Temperature (°C)", ylabel="Bike rentals",
                            width=640, height=420, alpha=0.8)
hv.save(hv_plot, "hvplot.html", resources="cdn")
```

hvPlot adds a `.hvplot` accessor to pandas (and Polars, Dask, and others) that works like `df.plot` but draws interactive charts. It uses Bokeh by default, so the toolbar looks the same. The `color` list is applied in the order the groups appear in the data, not alphabetically, which is why the code builds it from `df["season"].unique()`.

### pyecharts

```python
from pyecharts import options as opts
from pyecharts.charts import Scatter

sc = Scatter(init_opts=opts.InitOpts(width="640px", height="420px"))
for s in seasons:
    d = df[df["season"] == s]
    sc.add_xaxis(d["temp"].tolist())
    sc.add_yaxis(s, d["rentals"].tolist(), symbol_size=9, color=colors[s],
                 label_opts=opts.LabelOpts(is_show=False))
sc.set_global_opts(xaxis_opts=opts.AxisOpts(type_="value", name="Temperature (°C)", is_scale=True),
                   yaxis_opts=opts.AxisOpts(name="Bike rentals"),
                   tooltip_opts=opts.TooltipOpts(trigger="item"))
sc.render("pyecharts.html")
```

pyecharts wraps Apache ECharts. It takes plain lists rather than DataFrames, and you add one series per group yourself. In exchange you get ECharts' chart types and animations, which are popular in dashboards.

![Screenshots of the same temperature versus bike rentals scatter chart drawn by Plotly Express, Altair, Bokeh, hvPlot and pyecharts, plus a bar chart of their HTML file sizes](https://www.pythoncharts.com/python/python-interactive-charting-libraries-compared/images/python-interactive-charting-libraries-compared.png)

All five reproduce the same pattern. The visible differences are defaults: Plotly adds a blue-gray background and a right-hand legend, Altair and Bokeh use white grids, hvPlot's toolbar is Bokeh's, and pyecharts draws its axes through the origin.

## How Big Are the HTML Files?

With the JavaScript loaded from a CDN, every library's file for this 240-point chart is small: Bokeh 12 KB, Plotly 14 KB, Altair 15 KB, pyecharts 29 KB, hvPlot 34 KB. The CDN version needs internet access to open. Bundling the JavaScript so the file works offline changes the picture a lot:

- Plotly with `include_plotlyjs=True`: about 4.6 MB
- Bokeh with `resources=INLINE`: about 1.3 MB

If you email charts or embed many on one page, load plotly.js once from the CDN or share one copy rather than bundling it in every file. See [saving Plotly figures as standalone HTML files](https://www.pythoncharts.com/plotly/plotly-saving-standalone-html-files/).

## Which Python Interactive Charting Library Should You Use?

| Library | Style | Strengths | Trade-offs |
|---|---|---|---|
| Plotly Express | High-level functions, `fig.update_*` to customize | Widest chart range, Dash and Streamlit integration, great docs | Large bundled JS; Plotly template styling is distinctive |
| Altair | Declarative grammar (Vega-Lite) | Concise, consistent, linked selections | Fewer chart types; large datasets need aggregation or a data transformer |
| Bokeh | Lower-level glyphs and models | Fine control, widgets, `bokeh serve` for Python callbacks | More code for simple charts |
| hvPlot | `df.hvplot.*` accessor | One-liners on DataFrames, big-data backends, built on Bokeh | You still learn HoloViews and Bokeh for customization |
| pyecharts | Chart objects built from lists | ECharts' look, many chart types and animations | Lists rather than DataFrames; one series per group |

A rough decision path:

- Want the safest default, or need maps, 3D, or financial charts: **Plotly**.
- Want the shortest path from a DataFrame to an interactive plot: **hvPlot** or Plotly Express.
- Like writing charts as column-to-encoding mappings, or need linked brushing: **Altair**.
- Need server-side Python callbacks or full control of every element: **Bokeh**.
- Want ECharts' visual style: **pyecharts**.

**Highcharts** is another common name here. It is a JavaScript library, and its Python wrappers are separate packages and not covered above. Check its license terms before using it commercially.

## Practical Tips

- **Pick the app framework first.** [Streamlit](https://www.pythoncharts.com/streamlit/streamlit-charts-compared/) renders Plotly and Altair charts directly, and Dash is built around Plotly.
- **Watch the data size.** All of these ship your data to the browser. For tens of thousands of points, look at WebGL rendering (see [Plotly WebGL performance](https://www.pythoncharts.com/plotly/plotly-webgl-performance/)) or aggregate first.
- **Match a static fallback.** If you also need PNGs for reports, Plotly's Kaleido export and Altair's `vl-convert` both work; Bokeh needs a browser driver for static export.

## Similar Topics

- [Charts in Streamlit: st.line_chart vs Matplotlib vs Plotly vs Altair](https://www.pythoncharts.com/streamlit/streamlit-charts-compared/)
- [An Introduction to Altair](https://www.pythoncharts.com/altair/intro-to-altair/)
- [Customize Hover Tooltips in Plotly](https://www.pythoncharts.com/plotly/plotly-customize-hover-tooltips/)
