Hasty plotting for Altair, inspired by ggplot2's qplot
Project description
hastyplot
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
Features
- Auto geom selection -- x-only gives a histogram, x+y gives a scatter.
- Geoms --
"scatter","circle","line","bar","boxplot","hist". - Aesthetics --
color,size,opacity,group. - Smoothing --
smooth="loess"overlays a trend line. Also supports"linear","poly","log","exp","pow". Control loess wiggliness withbandwidth. - Faceting --
facet_col,facet_rowfor grids.facet_wrapwithcolumnsfor wrapped layouts. - Themes --
"default","clean","minimal"(data journalism style). - Pipe-friendly --
datais the first argument.
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", geom="boxplot")
# 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", geom="line", group="symbol")
# Histogram with custom bins
qplot(cars, "Horsepower", bins=20, theme="clean")
hastyplot.qplot.qplot
function
qplot(data, x: str, y: str | None = None, *, color: str | None = None, size: str | None = None, opacity: float | str = 0.7, group: str | None = None, geom: str = 'auto', smooth: str | None = None, bandwidth: float = 0.3, bins: int | None = None, facet_col: str | None = None, facet_row: str | None = None, facet_wrap: str | None = None, columns: int | None = None, width: int | None = None, height: int | None = None, title: str | None = None, subtitle: str | None = None, theme: str = 'default', actions: bool = False) -> altair.vegalite.v6.api.Chart
Quick plot for Altair. Inspired by ggplot2's qplot.
data is the first argument so you can use df.pipe(qplot, "x", "y").
Data & axes
data— DataFrame to plot.x— column for the x-axis.y— column for the y-axis. Omit for a histogram.
Aesthetics
color— column to map to 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.
Geom & smoothing
geom—"auto"picks"hist"for x-only,"scatter"for x+y. Options:"scatter","circle","line","bar","boxplot","hist".smooth— overlay a trend line:"loess","linear","poly","log","exp","pow".bandwidth— loess bandwidth, 0 to 1 (default0.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 (default3).
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 (defaultFalse).
| Name | Type | Default |
|---|---|---|
data |
||
x |
str |
|
y |
`str | None` |
color |
`str | None` |
size |
`str | None` |
opacity |
`float | str` |
group |
`str | None` |
geom |
str |
'auto' |
smooth |
`str | None` |
bandwidth |
float |
0.3 |
bins |
`int | None` |
facet_col |
`str | None` |
facet_row |
`str | None` |
facet_wrap |
`str | None` |
columns |
`int | None` |
width |
`int | None` |
height |
`int | None` |
title |
`str | None` |
subtitle |
`str | None` |
theme |
str |
'default' |
actions |
bool |
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hastyplot-0.1.0.tar.gz.
File metadata
- Download URL: hastyplot-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd6908c45ed298c9ad53d3069e9621fae48fceb47fe80ef6797b39d79ea3b85e
|
|
| MD5 |
10a3ddc7081abf4e7e0b4ca7dc88f76c
|
|
| BLAKE2b-256 |
597808417a8955d7b2be322cb9867c311800deda2e1ce558a890612b5d6f35ab
|
File details
Details for the file hastyplot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hastyplot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dce83e302a403d32c11c35c1cd1bd24a31269a9ba92e9d4df2e5ae201a126f9c
|
|
| MD5 |
d3c3721aa7869eaaaff4e7d8cdd03a62
|
|
| BLAKE2b-256 |
29e4fc3b6989e6a77580fc67dff2349bc109dccae12e331cb1df164539bf0f0c
|