liveBook · Manning

Plotly

As explained in DuckDB in Action

Plotly is a software library for creating interactive charts and data visualizations.

Plotly is a Python-friendly library for creating visually appealing, interactive charts through an intuitive API. It fits naturally into Streamlit applications, making queried data easier to explore and communicate. section 9.1.4 section 9.3

A practical Plotly workflow can:

  • Prepare and order data with DuckDB, then fetch it into a DataFrame. section 9.1.4
  • Construct a scatterplot with plotly.express, mapping columns to axes, color, point size, and category order. section 9.1.4
  • Render the resulting figure in Streamlit and extend it with vertical year markers. section 9.1.4

Tennis-match timeline

Create a scatterplot of Murray and Nadal matches, placing tournament dates on the x-axis, tournament names on the y-axis, winner names in color, and round importance in point size. Add a vertical line for each year to make the timeline easier to read. section 9.1.4

fig = px.scatter(sorted_matches_for_players,
    x="tourney_date",
    y="tourney_name",
    color="winner_name",
    size="roundOrder",
    color_discrete_sequence=px.colors.qualitative.Plotly,  #1
    category_orders={
        "tourney_name": (   #2
            sorted_matches_for_players['tourney_name']
            .drop_duplicates()
            .tolist()
        )
    },
)

Inspect the concise plotly.express construction pattern for a multi-encoding scatterplot. section 9.1.4

How DuckDB in Action covers it

How deep it goes
Demonstrates installation, imports, data ordering, scatterplot construction, Streamlit rendering, and chart annotations.
Examples
Uses a Murray–Nadal match timeline, winner colors, round-sized points, ordered tournaments, and vertical year lines.
What it assumes
Assumes Python, DuckDB queries, DataFrames, and a Streamlit application; teaches installation and basic plotly.express usage.
What you can do after
Build it from scratch by preparing a DataFrame, constructing an interactive Plotly chart, and rendering it with Streamlit.
How it connects
Connects interactive visualization with Python, DuckDB, DataFrames, Streamlit, and alternative tools such as Altair and Bokeh.

Also explained in

Compare how 2 books explain Plotly →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.