Skip to main content

Hasty plotting for Altair, inspired by ggplot2's qplot

Project description

hastyplot

This library is completely generated from a marimo notebook.

You can inspect the full implementation/docs/demo/test suite be clicking the button below.

Open in molab

Hasty plotting for Altair, inspired by ggplot2's qplot.

from hastyplot import qplot

# Scatter plot
qplot(df, "x", "y")

# Histogram (x-only)
qplot(df, "x")

# With pipe
df.pipe(qplot, "x", "y", color="group")

Install

uv add hastyplot

Examples

# Scatter with color and smooth
qplot(cars, "Horsepower", "Miles_per_Gallon",
      color="Origin", smooth="loess",
      title="HP vs MPG", theme="minimal")

# Boxplot
qplot(cars, "Origin", "Miles_per_Gallon", mark="boxplot")

# Matrix / heatmap from long-table data
qplot(matrix_df, "col", "row", mark="rect", color="value")

# Faceted scatter
qplot(cars, "Horsepower", "Miles_per_Gallon",
      facet_wrap="Cylinders", columns=3, width=200, height=150)

# Lines grouped without color
qplot(stocks, "date", "price", mark="line", group="symbol")

# Lines grouped with a fixed color
qplot(stocks, "date", "price", mark="line", group="symbol", color="#red")

# Histogram with custom bins
qplot(cars, "Horsepower", bins=20, theme="clean")

# Area chart
qplot(stocks, "date", "price", mark="area", color="symbol")

# Step chart
qplot(stocks, "date", "price", mark="step", color="symbol")

# With axis limits and tooltip
qplot(cars, "Horsepower", "Miles_per_Gallon",
      x_lim=(0, 250), y_lim=(None, 40),
      tooltip=["Name", "Origin"])

# Polynomial smooth
qplot(cars, "Horsepower", "Miles_per_Gallon", smooth="poly")

Themes

Pass the theme parameter to change the look of any chart:

qplot(df, "x", "y", theme="clean")
  • "default" — Altair's built-in styling, no customization applied.
  • "clean" — No gridlines, dark axis colors, system-ui fonts, bold title.
  • "minimal" — Light gridlines, no axis domain lines, Libre Franklin / Helvetica Neue fonts, bottom-oriented legend, and a custom color palette.

API

There is only one function and it is called qplot. In this function data is the first argument so you can use df.pipe(qplot, "x", "y"). Here's all the input options:

Data & axes

  • data — DataFrame to plot.
  • x — column for the x-axis.
  • y — column for the y-axis. Omit for a histogram.
  • x_lim / y_lim — axis limits as (min, max) tuples. Use None for an open bound.
  • tooltip — list of column names to show on hover.

Aesthetics

  • color — column to map to color. Use "#red" for a fixed named color value, or "#ff0000" for a fixed hex color.
  • size — column to map to point size.
  • opacity — a fixed float (e.g. 0.5) or a column name.
  • group — column to group by without changing color. Useful for separate lines per group in a uniform color.

Mark & smoothing

  • mark — options: "scatter", "circle", "line", "bar", "boxplot", "hist", "area", "step", "rect".
  • smooth — overlay a trend line: "loess", "linear", "poly", "log", "exp", "pow".
  • bandwidth — loess bandwidth, 0 to 1 (default 0.3). Lower = wigglier.
  • bins — number of histogram bins. Omit for Altair's default.

Faceting

  • facet_col / facet_row — column names for a facet grid.
  • facet_wrap — single column, wraps into rows.
  • columns — max columns before wrapping (default 3).

Layout & appearance

  • width / height — chart size in pixels (per panel when faceted).
  • title / subtitle — chart title and subtitle.
  • theme"default", "clean", or "minimal".
  • actions — show the Vega-Lite export menu (default False).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hastyplot-0.4.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hastyplot-0.4.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file hastyplot-0.4.0.tar.gz.

File metadata

  • Download URL: hastyplot-0.4.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for hastyplot-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dbc8542da382d4567da22db480b4c397717591a87f7a8fd472e8ba132778b38d
MD5 8de43297d46ca32a74ecb221f6b7882d
BLAKE2b-256 1c1e10ebdb69d91171c3c5cfe4e7ee78f6010368937bdb73e6bc369fac0f1e9f

See more details on using hashes here.

File details

Details for the file hastyplot-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: hastyplot-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for hastyplot-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6efbe40cfdac96aa497fc1005ca96a47f55fe2a20a7b371d10d870df75f56a67
MD5 06022329cc60c8569d88e4c3e397d89a
BLAKE2b-256 f435be38ca9e76df221bda2e9d543b43bf418cd606e9956b62bf37dc810382fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page