Repository navigation
Releases: vhrabar/kx-plot
Releases · vhrabar/kx-plot
Release list
v0.3.0
Added
- Plot kind
qq: sorted values against normal quantiles, one series per array orby=group, with a dashed
line through each one's quartiles. The quantiles come from Python'sstatistics, so no scipy is needed. - Plot kind
ridge: density curves stacked top to bottom, one per array orby=group, on one shared height
scale;overlap=sets the tallest ridge's height in rows.meanandmedianmark each ridge. - Plot kind
strip: every value as a point, one column per array orby=group, jittered sideways so ties
stay visible (the same way every run;jitter=sets the spread). Takesmeanandannlikebox. kx.grid(n, cols=3)makes a figure ofnpanels and returns them as a flat array of axes. Each panel gets
the theme's figure size, empty cells are removed, and constrained layout leaves room for colorbars and outside
legends. Other keywords go toplt.subplots.kx.save('fig.png')saves the current figure (or the one of a givenaxor figure) and returns the path.
A relative name goes to/kaggle/workingon Kaggle and to the current folder elsewhere; missing folders are
created. Without an extension the theme's format is used, sothesissaves a PDF.with kx.context(theme, palette=..., cmap=..., **rc):takes the same arguments askx.useand puts the
previous settings back when the block ends, also after an error.kx.parse(spec)returns aSpecwithkind,themeandflags. Printed, it is the canonical spec string
(kind, theme, then flags A–Z), andkx.plottakes aSpecwherever it takes a spec string. Mistyped tokens get
the closest valid ones as a hint.kx.plot(df, 'x', 'y', 'z', spec)names DataFrame columns, andby=can name a column. A mistyped column
gets the closest names as a hint.kx.plot(..., **kwargs)passes other keywords to the matplotlib call that draws the kind, over kx's defaults:
kx.plot(x, y, 'line', linewidth=3).bins=sets the sharedhistbins andwidth=(height=for
barh) the space each category's bars fill.- Flags for every kind
- Layout:
legoutputs the legend outside on the right, keeping a kind's legend title.rotrotates the x tick
labels 45°. - Axes:
logxy(log on both),symlogy(symmetric log y, so negatives work),zero(the value axis includes 0)
andeq(equal aspect). - Number format:
pct(0.25 → 25%) andsi(1500 → 1.5k) on the value axis, which is x forbarhand y
otherwise.
- Layout:
- Flags for some kinds
dateforline,step,area,bandandscatter:xis read as dates (text works too) and gets compact
date ticks.mkforline,step,areaandband: a marker on every point.sortforbarandbarh: largest first, byy, or by the total withstack.annforbarandbarh: the value on each bar, inside each segment withstack.meanandmedianforhist,kdeandecdf: a dashed / dotted line at each series' mean / median.
meanforboxandviolin: a diamond at each mean.annwrites the values.nocb,symandlogcforscatterwith a numericz: no colorbar, colour limits symmetric around 0,
log colour scale.
- Flags that ask for opposite things (
pctandsi,logyandlogxy,zeroand a log y,symandlogc)
raise an error.
Changed
- The
tightflag leaves a figure with constrained layout (such askx.grid's) alone instead of failing
when it has a colorbar.
Fixed
legandlegouton a plot with nothing to label, such asscatterwith a numericz, no longer warn
"No artists with labels found"; the plot just has no legend.
v0.2.0
Added
- Plot kinds
barh: horizontal bars, first category on top.yandzare grouped likebar.kde: smooth density curves (Gaussian KDE in numpy, no scipy needed), one per array.ecdf: empirical CDF, the share of values at or below each x, one step curve per array.box: box plots side by side (median, quartiles, 1.5 IQR whiskers, outliers), one per array.violin: violin plots side by side with the median and quartiles marked, one per array.
- Flags
stacknow works withbarandbarh:zis drawn on top ofy, so the bar's end is the total.stack,norm(density) and the newcum(cumulative) work withhist.
kx.plot(..., by=groups)splitsxinto one curve, box or violin per group (forkde,ecdf,box,violin).- cmocean colourmaps
thermal,haline,deepandbalanceforkx.use(cmap=...). - Crameri colourmaps (Scientific colour maps 8)
batlow,lipari,hawaii,oslo,davos,vik,roma,
bam,corkand cyclicromaO, vendored the same way. kx.use(cmap="<name>_r")reverses any colourmap inkx.cmaps().- Palettes
tollight(Paul Tol),set1andpaired(ColorBrewer) andtab20(Tableau, 20 categories).
Changed
histputs every series on the same bins, so overlaid bars line up.
v0.1.0
Added
- PyPI package:
pip install kx-plot, thenimport kx. The wheel ships the themes, palettes and demo CSVs. - Palettes: Paul Tol (
tolbright,tolvibrant,tolhc,tolmc), Petroff (petroff6,petroff8,petroff10),
Tableau (tab10,tableaucb), ColorBrewer (set2,dark2) andibm. Their licences are in
kx/styles/palettes/LICENCES.md.
Changed
kx.pyis now thekx/package, with the themes inkx/styles/and the demo CSVs inkx/data/.
kx.source()prints every file in the package.
Release v0.0.2
Added
Plot kinds
step: likeline, drawn as steps centred on each x.area: filled areas, overlapping and semi-transparent by default.area-stackstackszon top ofy, so the top edge is the total.area-normdraws a 100% stack with a percent y axis. Withleg, the legend goes outside on the right.
band: ayline with a shadedy ± zband in the same colour.zis required.scatterwith a text, bool or pandas categoricalzdraws one colour per category with a legend titled afterz. A numericzstill gets a colorbar.
Flags
stackandnorm. Both work withareaonly for now.
Themes
science: one journal column (3.5 in), 8 pt serif, inward ticks on all four sides, minor ticks, Paul Tol bright colours, saves at 600 dpi.talk: slides (16:9), 18 pt sans, thick lines, Okabe-Ito colours.poster: 12 × 9 in, 26 pt sans, very thick lines, saves at 300 dpi.thesis: A4 text width (160 mm), Computer Modern 10/9 pt without needing LaTeX, saves as PDF when the file name has no extension.
Palettes
- Named palettes live in
styles/palettes/<name>.txt, one hex colour per line. Any file added there is found automatically. okabe: the Okabe-Ito palette, 8 colours that stay distinguishable for every common type of colour blindness.kx.palettes()lists the palettes andkx.palette(name)returns a palette's colours.kx.use(theme, palette="okabe")accepts a palette name as well as a list of colours.
Colormaps
kx.use(theme, cmap=...)sets the colormap for continuous colour.- The supported matplotlib colormaps are
viridis,magma,plasma,inferno,cividis,turbo,twilight,coolwarm,berlin,managuaandvanimo. kx.cmaps()lists only the ones the installed matplotlib has.berlin,managuaandvanimoneed matplotlib 3.10 or newer.
Release v0.0.1
Initial Alpha release
Added
- Initial graphic capabilities
- demo preview showing available options