Skip to main content

kx-plot

One-line matplotlib plots and themes for notebooks and scripts.

kx is a small, plain-Python package with .mplstyle themes, palettes and colourmaps. It needs nothing beyond matplotlib, numpy and pandas and works offline, so it also runs in Kaggle competition notebooks.

dark theme

Install

pip install kx-plot
import kx; kx.use('dark')

Kaggle

Attach the dataset instead (Add Input → Datasets → vhrabar/kx-plot), then:

import sys; sys.path.append('/kaggle/input/datasets/vhrabar/kx-plot')
import kx; kx.use('dark')

Usage

kx.use('light', palette='okabe', cmap='cividis')   # notebook default: theme, palette, colormap
kx.plot(x, y, z, 'scatter-grid-leg')               # spec: kind-theme-flag-...
kx.plot(x, y, 'bar-paper')                         # a theme in the spec applies to this plot only
with kx.context('paper'): ...                      # or to every plot in the block
kx.save('fig.png')                                 # to /kaggle/working on Kaggle, else the current folder
for ax, col in zip(kx.grid(3), df.columns):        # a figure of 3 panels, a flat array of axes
    kx.plot(df, col, spec='hist', ax=ax)
kx.plot(df, 'month', 'y2025', 'bar')               # DataFrame columns by name
kx.plot(x, y, 'line', linewidth=3)                 # other keywords go to matplotlib
kx.plot(df, 'value', spec='kde', by='group')       # one density curve per group
kx.plot(df.value, spec='box', by=df.group)         # one box per group (also ridge, violin, qq)
Token Values
kind line step area band scatter bar barh hist kde ridge ecdf box violin
strip qq count crosstab hexbin heat missing nullmap
theme dark light paper science talk poster thesis
flags grid leg legout tight rot wrap logx logy logxy symlogy zero eq pct
si; per kind: stack norm cum date mk sort ann mean median nocb sym
logc corr all

stack works with area, bar, barh and hist. norm is a 100% stack for area and a density (area 1) for hist. cum makes hist cumulative; hist-norm-cum is the CDF. hist puts every series on the same bins, so the bars line up.

Unknown tokens raise an error instead of being guessed, with the closest valid tokens as a hint. Everything is inspectable: kx.grammar(), kx.grammar('area'), kx.parse('leg-scatter'), kx.show('dark'), kx.source('scatter').

Tables

kx.load('passengers') is a demo table with numbers, categories and NaNs to try these on.

kx.missing(df)                                     # share of NaNs per column, the most missing on top
kx.plot(df, 'nullmap-sort')                        # where the NaNs are: one pixel row per table row
kx.plot(df, 'heat-corr-ann')                       # correlations of the numeric columns, -1 to 1
kx.plot(df, 'heat')                                # any numeric DataFrame or 2-D array as coloured cells
kx.plot(df, 'pclass', spec='count', by='survived') # rows per category, split by a second column
kx.plot(df, 'pclass', 'port', 'crosstab-norm-ann') # how often each pair of categories occurs
kx.plot(df, 'age', 'fare', 'hexbin-logc')          # points per hexagon; with a z, its mean per hexagon

heat, missing and nullmap take the whole table and no column names; kx.plot(df[cols], 'heat') for some columns. wrap breaks long tick labels onto several lines.

rcParams can be overridden in kx.use with __ for dots: kx.use('dark', figure__figsize=(8, 4)).

Every kind, option, flag and config, with its output, is in the Example Usage notebook.

Palettes

Palettes for kx.use(theme, palette=...), they swap only the colours; a theme's other cycled properties (such as paper's linestyles) stay.

Name Source
okabe Okabe & Ito (2008)
tolbright tolvibrant tollight Paul Tol
tolhc tolmc Paul Tol
petroff6 petroff8 petroff10 Petroff (2021)
tab10 tab20 tableaucb Tableau
set1 set2 dark2 paired ColorBrewer
ibm IBM Design Colors

kx.palette('okabe') returns the hex codes. A list of colours works too: palette=['#264653', '#e9c46a'].

Colourmaps

Colourmaps for kx.use(theme, cmap=...) colour continuous values, such as a numeric z in scatter. Without cmap, the theme's own default applies. Add _r to any name to reverse it, e.g. cmap="thermal_r".

Name Type
viridis magma plasma inferno cividis Sequential, perceptually uniform
turbo Sequential, rainbow
blues greys Sequential, ColorBrewer
coolwarm Diverging
rdbu Diverging, ColorBrewer
berlin managua vanimo Diverging, dark centre
twilight Cyclic, for angles and phases
thermal haline deep Sequential, cmocean (vendored)
balance Diverging, cmocean (vendored)
batlow lipari hawaii oslo davos Sequential, Crameri (vendored)
vik roma bam cork Diverging, Crameri (vendored)
romaO Cyclic, Crameri (vendored)

kx.cmaps() lists the ones that are available in the installed matplotlib as those implemented in matplotlib 3.10 or newer are not vendored.

License

Released under the MIT License. See LICENSE.

Copyright © 2026 Vedran Hrabar

Vendored palettes and colourmaps keep their own licences; see kx/styles/palettes/LICENCES.md and kx/styles/cmaps/LICENCES.md.

Metadata

Release files for kx-plot 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kx-plot 0.4.0
File Size Uploaded Provenance
kx_plot-0.4.0.tar.gz 90.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kx-plot 0.4.0
File Interpreter ABI Platform
kx_plot-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 181.3 kB

Release files / kx_plot-0.4.0.tar.gz

Download URL kx_plot-0.4.0.tar.gz
Size 90.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8ab218ae0d74dcc6627c50742f76f1fbe94299b83b91069f2f5f34ff87e9e260
BLAKE2b-256 checksum
How to use checksums
e9aadbabc805fd5cd83757a7fa32d8ea80e513e6871c45a0b5e72b105eb14d5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / kx_plot-0.4.0-py3-none-any.whl

Download URL kx_plot-0.4.0-py3-none-any.whl
Size 91.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b1ea18d9aa94eaf435e9b08ab7162294f2983e25d9fbb430c4b3cc58b0986ab
BLAKE2b-256 checksum
How to use checksums
716415b884e81b3a3695f06f2ac41a86907a6d3df41cefe36396d9390596647f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Security for kx-plot 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kx_plot-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page