kx-plot 0.3.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. kx_plot-0.5.0/CHANGELOG.md +280 -0
  2. kx_plot-0.5.0/PKG-INFO +210 -0
  3. kx_plot-0.3.0/PKG-INFO → kx_plot-0.5.0/README.md +62 -31
  4. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/__init__.py +35 -8
  5. kx_plot-0.5.0/kx/_evaluate.py +80 -0
  6. kx_plot-0.5.0/kx/_metrics.py +176 -0
  7. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/_plot.py +51 -2
  8. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/_spec.py +6 -5
  9. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/_theme.py +11 -2
  10. kx_plot-0.5.0/kx/_util.py +57 -0
  11. kx_plot-0.5.0/kx/data/binary.csv +1001 -0
  12. kx_plot-0.5.0/kx/data/curves.csv +11 -0
  13. kx_plot-0.5.0/kx/data/history.csv +61 -0
  14. kx_plot-0.5.0/kx/data/importance.csv +16 -0
  15. kx_plot-0.5.0/kx/data/multiclass.csv +601 -0
  16. kx_plot-0.5.0/kx/data/passengers.csv +501 -0
  17. kx_plot-0.5.0/kx/data/regression.csv +501 -0
  18. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/kinds/__init__.py +1 -1
  19. kx_plot-0.5.0/kx/kinds/basic.py +213 -0
  20. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/kinds/dist.py +6 -1
  21. kx_plot-0.5.0/kx/kinds/ml.py +437 -0
  22. kx_plot-0.5.0/kx/kinds/table.py +132 -0
  23. {kx_plot-0.3.0 → kx_plot-0.5.0}/pyproject.toml +15 -4
  24. kx_plot-0.5.0/tests/test_kx.py +2029 -0
  25. kx_plot-0.3.0/CHANGELOG.md +0 -166
  26. kx_plot-0.3.0/README.md +0 -113
  27. kx_plot-0.3.0/kx/_util.py +0 -22
  28. kx_plot-0.3.0/kx/kinds/basic.py +0 -150
  29. kx_plot-0.3.0/tests/test_kx.py +0 -918
  30. {kx_plot-0.3.0 → kx_plot-0.5.0}/.gitignore +0 -0
  31. {kx_plot-0.3.0 → kx_plot-0.5.0}/LICENSE +0 -0
  32. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/_data.py +0 -0
  33. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/_files.py +0 -0
  34. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/_grid.py +0 -0
  35. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/_save.py +0 -0
  36. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/data/cloud.csv +0 -0
  37. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/data/daily.csv +0 -0
  38. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/data/dists.csv +0 -0
  39. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/data/monthly.csv +0 -0
  40. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/data/waves.csv +0 -0
  41. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/LICENCES.md +0 -0
  42. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/balance.txt +0 -0
  43. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/bam.txt +0 -0
  44. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/batlow.txt +0 -0
  45. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/cork.txt +0 -0
  46. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/davos.txt +0 -0
  47. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/deep.txt +0 -0
  48. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/haline.txt +0 -0
  49. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/hawaii.txt +0 -0
  50. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/lipari.txt +0 -0
  51. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/oslo.txt +0 -0
  52. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/roma.txt +0 -0
  53. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/romaO.txt +0 -0
  54. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/thermal.txt +0 -0
  55. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/cmaps/vik.txt +0 -0
  56. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/dark.mplstyle +0 -0
  57. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/light.mplstyle +0 -0
  58. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/LICENCES.md +0 -0
  59. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/dark2.txt +0 -0
  60. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/ibm.txt +0 -0
  61. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/okabe.txt +0 -0
  62. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/paired.txt +0 -0
  63. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/petroff10.txt +0 -0
  64. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/petroff6.txt +0 -0
  65. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/petroff8.txt +0 -0
  66. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/set1.txt +0 -0
  67. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/set2.txt +0 -0
  68. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/tab10.txt +0 -0
  69. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/tab20.txt +0 -0
  70. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/tableaucb.txt +0 -0
  71. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/tolbright.txt +0 -0
  72. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/tolhc.txt +0 -0
  73. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/tollight.txt +0 -0
  74. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/tolmc.txt +0 -0
  75. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/palettes/tolvibrant.txt +0 -0
  76. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/paper.mplstyle +0 -0
  77. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/poster.mplstyle +0 -0
  78. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/science.mplstyle +0 -0
  79. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/talk.mplstyle +0 -0
  80. {kx_plot-0.3.0 → kx_plot-0.5.0}/kx/styles/thesis.mplstyle +0 -0
  81. {kx_plot-0.3.0 → kx_plot-0.5.0}/tests/conftest.py +0 -0
@@ -0,0 +1,280 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.5.0] - 2026-10-24
10
+
11
+ ### Added
12
+
13
+ - `kx.roc_auc(y_true, score)` and `kx.pr_ap(y_true, score)`: the area under the ROC curve (by trapezoids) and
14
+ the average precision (the step sum `Σ (Rₙ − Rₙ₋₁) Pₙ`), in numpy with no scikit-learn needed, and tied scores
15
+ counted as one step as scikit-learn does. Labels are 0/1 or bool with `1`/`True` positive; with two other labels
16
+ the later one in sorted order is positive. More than two labels, a 2-D score or only one class raise.
17
+ - **Datasets** for the machine-learning kinds, for `kx.load`: `binary` (a 0/1 `y` scored by two models, `gbm`
18
+ ranking better and `logreg` better calibrated), `multiclass` (a 3-class `y`, one probability column per class
19
+ `cat`, `dog`, `bird` summing to 1, and `pred`), `regression` (`actual`, `predicted` and an `x` the error grows
20
+ with), `history` (`loss`, `val_loss`, `accuracy`, `val_accuracy` per `epoch`, overfitting after about 30 epochs),
21
+ `importance` (`feature`, `importance`, `std`) and `curves` (learning-curve scores per training `size`,
22
+ `train_1..5` and `val_1..5`). `scripts/make_ml.py` writes them with a fixed seed.
23
+ - **Flag** `diag` (`scatter`, `hexbin`): a dashed `y = x` line across the range `x` and `y` share, to compare
24
+ predicted with actual values or two measurements of the same thing.
25
+ - **Flag** `fit` (`scatter`): a least-squares line with its slope and R² in the legend, which it draws. With a
26
+ categorical `z`, one line per group in the group's colour. With a log axis it raises, because a straight fit
27
+ is a curve there; fit the logs instead.
28
+ - **Plot kind** `cm`: a confusion matrix, `kx.plot(y_true, y_pred, 'cm')`, with the true classes down the rows
29
+ and the predicted ones along the columns, as in scikit-learn. Every label of either array gets a row and a
30
+ column, so a class that is never predicted still shows. `norm` divides each row by its total (the recall of
31
+ each class) with a percent colorbar, `ann` writes each cell's value and `nocb` drops the colorbar. A 2-D
32
+ `y_pred` raises with a hint to pass `proba.argmax(axis=1)`.
33
+ - **Plot kind** `roc`: the ROC curve, `kx.plot(y_true, score, 'roc')`, with the AUC in the legend
34
+ (`gbm (AUC 0.80)`), which it draws without `leg`. A dotted diagonal marks a random model, and both axes run
35
+ from 0 to 1 at equal scale. `z` adds a second model's score. A 2-D score, one column per class, draws one
36
+ curve per class, one-vs-rest, named after the DataFrame's columns or else the sorted labels of `y_true`.
37
+ - **Plot kind** `pr`: the precision-recall curve, `kx.plot(y_true, score, 'pr')`, with the average precision in
38
+ the legend (`gbm (AP 0.80)`) and a dotted baseline at the positive rate, what a random model gets. The curve
39
+ is drawn in the steps that the average precision sums. `z` adds a second model on the same baseline; a 2-D
40
+ score draws one curve per class, each with its own baseline in its colour.
41
+ - **Plot kind** `calib`: a reliability diagram, `kx.plot(y_true, score, 'calib')`: the observed positive rate
42
+ against the mean score in `bins=` equal-width bins over 0..1 (10 by default), with markers sized by the rows
43
+ in each bin, the diagonal a calibrated model lies on, and the Brier score in the legend (`gbm (Brier 0.201)`).
44
+ Empty bins are left out. `z` adds a second model; scores outside 0..1 raise.
45
+ - **Plot kind** `proba`: the score distribution per true class, `kx.plot(y_true, score, 'proba')`: one
46
+ histogram per class on the same `bins=` equal-width bins over 0..1 (20 by default), so their overlap shows
47
+ where the model confuses them. `norm` draws densities, for imbalanced classes. A 2-D score shows each row's
48
+ score for its own true class.
49
+ - **Plot kind** `thresh`: precision, recall and F1 against the decision threshold,
50
+ `kx.plot(y_true, score, 'thresh')`, where a row is positive when its score is at or above the threshold.
51
+ - **Flag** `best` (`thresh`, `loss`, `elbow`): a dashed vertical line at the threshold with the highest F1, labelled in the legend
52
+ (`best F1 0.74 at 0.38`).
53
+ - **Plot kinds** `gain` and `lift`: `kx.plot(y_true, score, 'gain')` draws the share of positives found against
54
+ the share of rows taken, highest scores first, between a dotted diagonal (a random order) and a dashed corner
55
+ at the positive rate (a perfect one). `lift` divides the gain by the random order's, so how many times more
56
+ positives the top rows hold, with a dotted line at 1. `z` adds a second model to both.
57
+ - **Plot kind** `pva`: predicted against actual for a regression, `kx.plot(actual, predicted, 'pva')`, with the
58
+ dashed `y = x` line, equal scales, and R², RMSE and MAE in the corner. Above 5,000 points it draws hexagons
59
+ (`hexbin`) instead of dots, so big test sets stay readable.
60
+ - **Plot kind** `resid`: residuals (`actual - predicted`) against predicted, with a dashed line at 0. `z` colours
61
+ the points as in `scatter`, such as by a feature, and takes `nocb`, `sym` and `logc`.
62
+ - **Plot kind** `imp`: feature importance, `kx.plot(df, 'feature', 'importance', 'std', 'imp')`, as bars lying
63
+ down with the largest on top and `z` as error bars. `top=` keeps the largest (20 by default) and the y label
64
+ says how many were left out.
65
+ - **Plot kind** `loss`: training curves, `kx.plot(history, 'loss')`. The first metric is a solid line and its
66
+ `val_` pair a dashed one in the same colour, against an `epoch` column or the row number from 1. Other metrics
67
+ have other scales, so `kx.plot(h[['accuracy', 'val_accuracy']], 'loss')` draws them. `best` marks the best
68
+ validation epoch: the lowest, or the highest for metrics named with `acc`, `auc`, `f1`, `precision` or `recall`.
69
+ - Table kinds also take a dict of columns, or anything with a `.history` dict such as a Keras `History`, so
70
+ `kx.plot(model.fit(...), 'loss')` works without importing Keras.
71
+ - **Plot kinds** `lcurve` and `vcurve`: cross-validated scores, `kx.plot(sizes, train_scores, val_scores,
72
+ 'lcurve')`, in the shapes scikit-learn's `learning_curve` and `validation_curve` return (one row per x, one
73
+ column per fold). The mean is a line and ± one standard deviation a band in its colour; 1-D scores draw a line
74
+ without a band. `vcurve` is the same with a hyperparameter on x, so `logx` is the usual flag.
75
+ - **Plot kind** `elbow`: choosing the number of clusters, `kx.plot(ks, inertia, 'elbow')`, with `z` (such as the
76
+ silhouette score) on a second y axis on the right. `best` marks the knee: the point farthest from the line
77
+ between the first and last points, with both axes scaled to 0..1.
78
+ - `kx.evaluate(y_true, *scores)`: a model report in one figure, with the panels picked from the data. A binary
79
+ `y` with 1-D scores gets `roc`, `pr`, `calib` and `proba` (2 x 2), with up to two models in each panel but
80
+ `proba`. A 2-D score gets `roc` per class, the `cm` of the most likely class and `proba` of the true class. A
81
+ numeric `y` with more than 10 values gets `pva`, `resid` and a `hist` of the residuals. `spec=` adds a theme and
82
+ flags to every panel, and other keywords go to `kx.grid`. It returns the flat array of axes, as `kx.grid` does;
83
+ the figure is `axs[0].figure`.
84
+
85
+ ## [0.4.0] - 2026-10-18
86
+
87
+ ### Added
88
+
89
+ - **Plot kind** `heat`: a DataFrame or 2-D array as coloured cells, columns along x and index labels down y.
90
+ `corr` draws the correlations of the numeric columns on `rdbu` from -1 to 1, and `ann` writes each cell's value
91
+ in black or white, whichever reads on that cell. Takes `nocb`, `sym` and `logc` like `scatter`.
92
+ - **Plot kind** `crosstab`: how often each pair of categories occurs, as a heat map with `x` along the x axis and
93
+ `y` down the y axis: `kx.plot(df, 'sex', 'pclass', 'crosstab-ann')`. `norm` shows shares within each `x`
94
+ category (each column sums to 100%), and `logc` leaves pairs that never occur blank.
95
+ - **Plot kind** `count`: how often each category of `x` occurs, with missing values as their own `NaN` bar.
96
+ `by=` splits each bar into one per group (`kx.plot(df, 'pclass', spec='count', by='survived')`). `stack` puts the
97
+ groups on top of each other, `sort` puts the most common first and `ann` writes the counts. `norm` shows shares:
98
+ within each category with `by=` and `stack`, and within each group otherwise.
99
+ - **Plot kind** `missing`: the share of missing values in each column of a DataFrame, as bars lying down with
100
+ the most missing on top: `kx.plot(df, 'missing-ann')`. Columns without missing values show only with `all`,
101
+ and a frame with none shows "no missing values" instead of raising.
102
+ - **Plot kind** `nullmap`: where the missing values are, one row of the image per row of the table and the
103
+ columns along x. Missing cells are in the palette's first colour on the theme's background. `sort` puts the rows
104
+ with the most missing values on top and groups rows with the same gaps, so patterns show as blocks.
105
+ - **Plot kind** `hexbin`: how many points fall in each hexagon, or with `z` the mean of `z` there, with a
106
+ colorbar labelled `count` or with `z`'s name. Rows with a NaN are left out. Takes `nocb` and `logc` (`sym` with
107
+ `z` only), and `gridsize=` sets the number of hexagons across.
108
+ - `kx.missing(df)`: the same as `kx.plot(df, 'missing-ann')`. A spec adds a theme and flags,
109
+ `kx.missing(df, 'dark-wrap')`, and other keywords such as `title=` and `ax=` go to `kx.plot`.
110
+ - **Flag for every kind** `wrap`: long text tick labels break into lines of at most 12 characters at spaces,
111
+ on both axes. Numbers, dates and single long words are left as they are. Works together with `rot`.
112
+ - `kx.plot(df, spec)` and `kx.plot(matrix, spec)` hand the whole table to a table kind, with no column names. A
113
+ 2-D array becomes a DataFrame labelled `0..n`. A table kind given columns, `y`, `z` or `by=` raises, and
114
+ `kx.grammar(kind)` says it takes a DataFrame or 2-D array.
115
+ - **Colourmaps** `blues`, `greys` and `rdbu`: lowercase names for matplotlib's ColorBrewer `Blues`, `Greys` and
116
+ `RdBu`, for `kx.use(cmap=...)` and in `kx.cmaps()`. `_r` reverses them like the others.
117
+ - **Demo dataset** `passengers`: 500 synthetic passengers (`age`, `fare`, `sex`, `pclass`, `port`, `deck`,
118
+ `ticket_type`, `survived`) with missing ages, decks and ports, for the table kinds: `kx.load('passengers')`.
119
+ It is generated by `scripts/make_passengers.py`, not taken from the Titanic data.
120
+
121
+ ## [0.3.0] - 2026-10-12
122
+
123
+ ### Added
124
+
125
+ - **Plot kind** `qq`: sorted values against normal quantiles, one series per array or `by=` group, with a dashed
126
+ line through each one's quartiles. The quantiles come from Python's `statistics`, so no scipy is needed.
127
+ - **Plot kind** `ridge`: density curves stacked top to bottom, one per array or `by=` group, on one shared height
128
+ scale; `overlap=` sets the tallest ridge's height in rows. `mean` and `median` mark each ridge.
129
+ - **Plot kind** `strip`: every value as a point, one column per array or `by=` group, jittered sideways so ties
130
+ stay visible (the same way every run; `jitter=` sets the spread). Takes `mean` and `ann` like `box`.
131
+ - `kx.grid(n, cols=3)` makes a figure of `n` panels and returns them as a flat array of axes. Each panel gets
132
+ the theme's figure size, empty cells are removed, and constrained layout leaves room for colorbars and outside
133
+ legends. Other keywords go to `plt.subplots`.
134
+ - `kx.save('fig.png')` saves the current figure (or the one of a given `ax` or figure) and returns the path.
135
+ A relative name goes to `/kaggle/working` on Kaggle and to the current folder elsewhere; missing folders are
136
+ created. Without an extension the theme's format is used, so `thesis` saves a PDF.
137
+ - `with kx.context(theme, palette=..., cmap=..., **rc):` takes the same arguments as `kx.use` and puts the
138
+ previous settings back when the block ends, also after an error.
139
+ - `kx.parse(spec)` returns a `Spec` with `kind`, `theme` and `flags`. Printed, it is the canonical spec string
140
+ (kind, theme, then flags A–Z), and `kx.plot` takes a `Spec` wherever it takes a spec string. Mistyped tokens get
141
+ the closest valid ones as a hint.
142
+ - `kx.plot(df, 'x', 'y', 'z', spec)` names DataFrame columns, and `by=` can name a column. A mistyped column
143
+ gets the closest names as a hint.
144
+ - `kx.plot(..., **kwargs)` passes other keywords to the matplotlib call that draws the kind, over kx's defaults:
145
+ `kx.plot(x, y, 'line', linewidth=3)`. `bins=` sets the shared `hist` bins and `width=` (`height=` for
146
+ `barh`) the space each category's bars fill.
147
+ - **Flags for every kind**
148
+ - Layout: `legout` puts the legend outside on the right, keeping a kind's legend title. `rot` rotates the x tick
149
+ labels 45°.
150
+ - Axes: `logxy` (log on both), `symlogy` (symmetric log y, so negatives work), `zero` (the value axis includes 0)
151
+ and `eq` (equal aspect).
152
+ - Number format: `pct` (0.25 → 25%) and `si` (1500 → 1.5k) on the value axis, which is x for `barh` and y
153
+ otherwise.
154
+ - **Flags for some kinds**
155
+ - `date` for `line`, `step`, `area`, `band` and `scatter`: `x` is read as dates (text works too) and gets compact
156
+ date ticks.
157
+ - `mk` for `line`, `step`, `area` and `band`: a marker on every point.
158
+ - `sort` for `bar` and `barh`: largest first, by `y`, or by the total with `stack`.
159
+ - `ann` for `bar` and `barh`: the value on each bar, inside each segment with `stack`.
160
+ - `mean` and `median` for `hist`, `kde` and `ecdf`: a dashed / dotted line at each series' mean / median.
161
+ `mean` for `box` and `violin`: a diamond at each mean. `ann` writes the values.
162
+ - `nocb`, `sym` and `logc` for `scatter` with a numeric `z`: no colorbar, colour limits symmetric around 0,
163
+ log colour scale.
164
+ - Flags that ask for opposite things (`pct` and `si`, `logy` and `logxy`, `zero` and a log y, `sym` and `logc`)
165
+ raise an error.
166
+
167
+ ### Changed
168
+
169
+ - The `tight` flag leaves a figure with constrained layout (such as `kx.grid`'s) alone instead of failing
170
+ when it has a colorbar.
171
+
172
+ ### Fixed
173
+
174
+ - `leg` and `legout` on a plot with nothing to label, such as `scatter` with a numeric `z`, no longer warn
175
+ "No artists with labels found"; the plot just has no legend.
176
+
177
+ ## [0.2.0] - 2026-10-09
178
+
179
+ ### Added
180
+
181
+ - **Plot kinds**
182
+ - `barh`: horizontal bars, first category on top. `y` and `z` are grouped like `bar`.
183
+ - `kde`: smooth density curves (Gaussian KDE in numpy, no scipy needed), one per array.
184
+ - `ecdf`: empirical CDF, the share of values at or below each x, one step curve per array.
185
+ - `box`: box plots side by side (median, quartiles, 1.5 IQR whiskers, outliers), one per array.
186
+ - `violin`: violin plots side by side with the median and quartiles marked, one per array.
187
+ - **Flags**
188
+ - `stack` now works with `bar` and `barh`: `z` is drawn on top of `y`, so the bar's end is the total.
189
+ - `stack`, `norm` (density) and the new `cum` (cumulative) work with `hist`.
190
+ - `kx.plot(..., by=groups)` splits `x` into one curve, box or violin per group (for `kde`, `ecdf`, `box`, `violin`).
191
+ - cmocean colourmaps `thermal`, `haline`, `deep` and `balance` for `kx.use(cmap=...)`.
192
+ - Crameri colourmaps (Scientific colour maps 8) `batlow`, `lipari`, `hawaii`, `oslo`, `davos`, `vik`, `roma`,
193
+ `bam`, `cork` and cyclic `romaO`, vendored the same way.
194
+ - `kx.use(cmap="<name>_r")` reverses any colourmap in `kx.cmaps()`.
195
+ - Palettes `tollight` (Paul Tol), `set1` and `paired` (ColorBrewer) and `tab20` (Tableau, 20 categories).
196
+
197
+ ### Changed
198
+
199
+ - `hist` puts every series on the same bins, so overlaid bars line up.
200
+
201
+ ## [0.1.0] - 2026-10-08
202
+
203
+ ### Added
204
+
205
+ - **PyPI package:** `pip install kx-plot`, then `import kx`. The wheel ships the themes, palettes and demo CSVs.
206
+ - **Palettes:** Paul Tol (`tolbright`, `tolvibrant`, `tolhc`, `tolmc`), Petroff (`petroff6`, `petroff8`, `petroff10`),
207
+ Tableau (`tab10`, `tableaucb`), ColorBrewer (`set2`, `dark2`) and `ibm`. Their licences are in
208
+ `kx/styles/palettes/LICENCES.md`.
209
+
210
+ ### Changed
211
+
212
+ - **`kx.py` is now the `kx/` package**, with the themes in `kx/styles/` and the demo CSVs in `kx/data/`.
213
+ `kx.source()` prints every file in the package.
214
+
215
+ ## [0.0.2] - 2026-10-08
216
+
217
+ ### Added
218
+
219
+ - **Plot kinds**
220
+ - `step`: like `line`, drawn as steps centred on each x.
221
+ - `area`: filled areas, overlapping and semi-transparent by default.
222
+ - `area-stack` stacks `z` on top of `y`, so the top edge is the total.
223
+ - `area-norm` draws a 100% stack with a percent y axis. With `leg`, the legend goes outside on the right.
224
+ - `band`: a `y` line with a shaded `y ± z` band in the same colour. `z` is required.
225
+ - `scatter` with a text, bool or pandas categorical `z` draws one colour per category with a legend titled after `z`. A numeric `z` still gets a colorbar.
226
+ - **Flags**
227
+ - `stack` and `norm`. Both work with `area` only for now.
228
+ - **Themes**
229
+ - `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.
230
+ - `talk`: slides (16:9), 18 pt sans, thick lines, Okabe-Ito colours.
231
+ - `poster`: 12 × 9 in, 26 pt sans, very thick lines, saves at 300 dpi.
232
+ - `thesis`: A4 text width (160 mm), Computer Modern 10/9 pt without needing LaTeX, saves as PDF when the file name has no extension.
233
+ - **Palettes**
234
+ - Named palettes live in `styles/palettes/<name>.txt`, one hex colour per line. Any file added there is found automatically.
235
+ - `okabe`: the Okabe-Ito palette, 8 colours that stay distinguishable for every common type of colour blindness.
236
+ - `kx.palettes()` lists the palettes and `kx.palette(name)` returns a palette's colours.
237
+ - `kx.use(theme, palette="okabe")` accepts a palette name as well as a list of colours.
238
+ - **Colormaps**
239
+ - `kx.use(theme, cmap=...)` sets the colormap for continuous colour.
240
+ - The supported matplotlib colormaps are `viridis`, `magma`, `plasma`, `inferno`, `cividis`, `turbo`, `twilight`, `coolwarm`, `berlin`, `managua` and `vanimo`.
241
+ - `kx.cmaps()` lists only the ones the installed matplotlib has. `berlin`, `managua` and `vanimo` need matplotlib 3.10 or newer.
242
+ - **Docs**
243
+ - `Example Usage.ipynb`: a detailed walkthrough for the public Kaggle notebook. It loads `kx` from the attached dataset.
244
+ - `kx.grammar()` lists the palettes and colormaps as well as the kinds, themes and flags.
245
+
246
+ ### Changed
247
+
248
+ - **`paper` theme, reworked for greyscale print:**
249
+ - black, dark grey and mid grey colours, each paired with a linestyle (solid, dashed, dotted, dash-dot)
250
+ - greyscale colormap
251
+ - 300 dpi export with a white background
252
+ - serif font for maths text as well
253
+ - 110 dpi in notebooks instead of 150
254
+ - **Palettes keep the theme's other cycled properties:** they replace only the colours, so `paper` + `okabe` keeps `paper`'s linestyles.
255
+ - **`scatter` point size follows the theme's `lines.markersize`.** Points are bigger on `poster` and smaller on `science`. `dark` and `light` look the same as before.
256
+ - **Preview images:** each theme's preview is drawn at twice that theme's own figure size instead of a fixed 12×6 in, so `talk` and `poster` previews no longer overlap.
257
+ - **`previews/demo.ipynb`:** cut down to a short demo of each kind and theme. The full walkthrough is now `Example Usage.ipynb`.
258
+ - **Strict errors** also cover:
259
+ - `stack` or `norm` on a kind that doesn't support them
260
+ - `band` without `z`
261
+ - `area-norm` with only one series
262
+
263
+ ## [0.0.1] - 2026-10-07
264
+
265
+ ### Added
266
+
267
+ - `kx.plot` with the kinds `line`, `scatter`, `bar` and `hist`
268
+ - the flags `grid`, `leg`, `logx`, `logy` and `tight`
269
+ - the themes `dark`, `light` and `paper`
270
+ - `kx.use`, `kx.show`, `kx.source`, `kx.grammar`, `kx.load` and the demo CSVs
271
+ - a workflow that publishes the dataset to Kaggle
272
+
273
+ [Unreleased]: https://github.com/vhrabar/kx-plot/compare/v0.5.0...HEAD
274
+ [0.5.0]: https://github.com/vhrabar/kx-plot/compare/v0.4.0...v0.5.0
275
+ [0.4.0]: https://github.com/vhrabar/kx-plot/compare/v0.3.0...v0.4.0
276
+ [0.3.0]: https://github.com/vhrabar/kx-plot/compare/v0.2.0...v0.3.0
277
+ [0.2.0]: https://github.com/vhrabar/kx-plot/compare/v0.1.0...v0.2.0
278
+ [0.1.0]: https://github.com/vhrabar/kx-plot/compare/v0.0.2...v0.1.0
279
+ [0.0.2]: https://github.com/vhrabar/kx-plot/compare/v0.0.1...v0.0.2
280
+ [0.0.1]: https://github.com/vhrabar/kx-plot/releases/tag/v0.0.1
kx_plot-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.5
2
+ Name: kx-plot
3
+ Version: 0.5.0
4
+ Summary: One-line matplotlib plots, themes and model-evaluation charts for notebooks and scripts, Kaggle-friendly
5
+ Project-URL: Homepage, https://github.com/vhrabar/kx-plot
6
+ Project-URL: Issues, https://github.com/vhrabar/kx-plot/issues
7
+ Project-URL: Changelog, https://github.com/vhrabar/kx-plot/blob/main/CHANGELOG.md
8
+ Project-URL: Kaggle, https://www.kaggle.com/datasets/vhrabar/kx-plot
9
+ Project-URL: Example Notebook, https://www.kaggle.com/code/vhrabar/kx-one-line-matplotlib-plots-and-themes
10
+ Author-email: Vedran Hrabar <vedran.hrabar@outlook.com>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ License-File: kx/styles/cmaps/LICENCES.md
14
+ License-File: kx/styles/palettes/LICENCES.md
15
+ Keywords: confusion-matrix,data-science,jupyter,kaggle,machine-learning,matplotlib,model-evaluation,plotting,roc-curve,themes,visualization
16
+ Classifier: Development Status :: 4 - Beta
17
+ Classifier: Framework :: Jupyter
18
+ Classifier: Framework :: Matplotlib
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Intended Audience :: Education
21
+ Classifier: Intended Audience :: Science/Research
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Programming Language :: Python :: 3 :: Only
25
+ Classifier: Programming Language :: Python :: 3.10
26
+ Classifier: Programming Language :: Python :: 3.11
27
+ Classifier: Programming Language :: Python :: 3.12
28
+ Classifier: Programming Language :: Python :: 3.13
29
+ Classifier: Programming Language :: Python :: 3.14
30
+ Classifier: Programming Language :: Python :: 3.15
31
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
32
+ Classifier: Topic :: Scientific/Engineering :: Visualization
33
+ Requires-Python: >=3.10
34
+ Requires-Dist: matplotlib>=3.7
35
+ Requires-Dist: numpy>=1.23
36
+ Requires-Dist: pandas>=1.5
37
+ Description-Content-Type: text/markdown
38
+
39
+ # kx-plot
40
+
41
+ One-line matplotlib plots and themes for notebooks and scripts.
42
+
43
+ `kx` is a small, plain-Python package with `.mplstyle` themes, palettes and colourmaps. It needs nothing beyond
44
+ matplotlib, numpy and pandas and works offline, so it also runs in Kaggle competition notebooks.
45
+
46
+ ![dark theme](https://raw.githubusercontent.com/vhrabar/kx-plot/main/previews/dark.png)
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ pip install kx-plot
52
+ ```
53
+
54
+ ```python
55
+ import kx; kx.use('dark')
56
+ ```
57
+
58
+ ### Kaggle
59
+
60
+ Attach the dataset instead (**Add Input → Datasets → `vhrabar/kx-plot`**), then:
61
+
62
+ ```python
63
+ import sys; sys.path.append('/kaggle/input/datasets/vhrabar/kx-plot')
64
+ import kx; kx.use('dark')
65
+ ```
66
+
67
+ ## Usage
68
+
69
+ ```python
70
+ kx.use('light', palette='okabe', cmap='cividis') # notebook default: theme, palette, colormap
71
+ kx.plot(x, y, z, 'scatter-grid-leg') # spec: kind-theme-flag-...
72
+ kx.plot(x, y, 'bar-paper') # a theme in the spec applies to this plot only
73
+ with kx.context('paper'): ... # or to every plot in the block
74
+ kx.save('fig.png') # to /kaggle/working on Kaggle, else the current folder
75
+ for ax, col in zip(kx.grid(3), df.columns): # a figure of 3 panels, a flat array of axes
76
+ kx.plot(df, col, spec='hist', ax=ax)
77
+ kx.plot(df, 'month', 'y2025', 'bar') # DataFrame columns by name
78
+ kx.plot(x, y, 'line', linewidth=3) # other keywords go to matplotlib
79
+ kx.plot(df, 'value', spec='kde', by='group') # one density curve per group
80
+ kx.plot(df.value, spec='box', by=df.group) # one box per group (also ridge, violin, qq)
81
+ ```
82
+
83
+ | Token | Values |
84
+ |-------|-----------------------------------------------------------------------------------------------|
85
+ | kind | `line` `step` `area` `band` `scatter` `bar` `barh` `hist` `kde` `ridge` `ecdf` `box` `violin` |
86
+ | | `strip` `qq` `count` `crosstab` `hexbin` `heat` `missing` `nullmap` |
87
+ | | ML: `cm` `roc` `pr` `calib` `proba` `thresh` `gain` `lift` `pva` `resid` `imp` `loss` |
88
+ | | `lcurve` `vcurve` `elbow` |
89
+ | theme | `dark` `light` `paper` `science` `talk` `poster` `thesis` |
90
+ | flags | `grid` `leg` `legout` `tight` `rot` `wrap` `logx` `logy` `logxy` `symlogy` `zero` `eq` `pct` |
91
+ | | `si`; per kind: `stack` `norm` `cum` `date` `mk` `sort` `ann` `mean` `median` `nocb` `sym` |
92
+ | | `logc` `corr` `all` `diag` `fit` `best` |
93
+
94
+ `stack` works with `area`, `bar`, `barh` and `hist`. `norm` is a 100% stack for `area` and a
95
+ density (area 1) for `hist`. `cum` makes `hist` cumulative; `hist-norm-cum` is the CDF.
96
+ `hist` puts every series on the same bins, so the bars line up.
97
+ `diag` adds a dashed `y = x` line to `scatter` and `hexbin`; `fit` adds a least-squares line to `scatter`, with
98
+ its slope and R² in the legend (one line per group with a categorical `z`).
99
+
100
+ Unknown tokens raise an error instead of being guessed, with the closest valid tokens as a hint.
101
+ Everything is inspectable: `kx.grammar()`, `kx.grammar('area')`, `kx.parse('leg-scatter')`, `kx.show('dark')`,
102
+ `kx.source('scatter')`.
103
+
104
+ ### Tables
105
+
106
+ `kx.load('passengers')` is a demo table with numbers, categories and NaNs to try these on.
107
+
108
+ ```python
109
+ kx.missing(df) # share of NaNs per column, the most missing on top
110
+ kx.plot(df, 'nullmap-sort') # where the NaNs are: one pixel row per table row
111
+ kx.plot(df, 'heat-corr-ann') # correlations of the numeric columns, -1 to 1
112
+ kx.plot(df, 'heat') # any numeric DataFrame or 2-D array as coloured cells
113
+ kx.plot(df, 'pclass', spec='count', by='survived') # rows per category, split by a second column
114
+ kx.plot(df, 'pclass', 'port', 'crosstab-norm-ann') # how often each pair of categories occurs
115
+ kx.plot(df, 'age', 'fare', 'hexbin-logc') # points per hexagon; with a z, its mean per hexagon
116
+ ```
117
+
118
+ `heat`, `missing` and `nullmap` take the whole table and no column names; `kx.plot(df[cols], 'heat')` for some
119
+ columns. `wrap` breaks long tick labels onto several lines.
120
+
121
+ ### Machine learning
122
+
123
+ `kx.load('binary')`, `'multiclass'`, `'regression'`, `'history'`, `'importance'` and `'curves'` are demo data for
124
+ these kinds. Metrics are computed in numpy: no scikit-learn needed.
125
+
126
+ ```python
127
+ kx.plot(y_true, score, 'roc') # ROC curve, AUC in the legend
128
+ kx.plot(y_true, gbm, logreg, 'pr') # a second model goes in z; AP and a random baseline
129
+ kx.plot(y_true, proba_df, 'roc') # a 2-D score: one curve per class, one-vs-rest
130
+ kx.plot(y_true, score, 'calib') # reliability diagram, Brier score in the legend
131
+ kx.plot(y_true, score, 'proba') # score histogram per true class
132
+ kx.plot(y_true, score, 'thresh-best') # precision, recall and F1 against the threshold
133
+ kx.plot(y_true, score, 'gain') # also 'lift'
134
+ kx.plot(y_true, y_pred, 'cm-norm-ann') # confusion matrix, each row the recall of a class
135
+ kx.plot(actual, predicted, 'pva') # predicted vs actual, R², RMSE and MAE
136
+ kx.plot(actual, predicted, feature, 'resid') # residuals, coloured by a feature
137
+ kx.plot(df, 'feature', 'importance', 'std', 'imp') # feature importance with error bars, top= 20
138
+ kx.plot(model.fit(...), 'loss-best') # training curves from a Keras History, dict or DataFrame
139
+ kx.plot(sizes, train_scores, val_scores, 'lcurve') # scikit-learn's learning_curve output; also 'vcurve'
140
+ kx.plot(ks, inertia, silhouette, 'elbow-best') # choosing k, the knee marked
141
+ kx.roc_auc(y_true, score), kx.pr_ap(y_true, score) # the metrics as numbers
142
+ kx.evaluate(y_true, gbm, logreg) # a report: the panels picked from the data
143
+ ```
144
+
145
+ The truth comes first, then the predictions. Binary labels are 0/1 or bool, with `1`/`True` the positive class;
146
+ with two other labels the later one in sorted order is positive. For multiclass, pass a 2-D score with one column
147
+ per class: the class names are the DataFrame's columns, or else the sorted labels of `y_true`. `roc`, `pr`, `calib`,
148
+ `gain` and `lift` draw their legend without `leg`, because the metric in it is the point of the plot.
149
+
150
+ `kx.evaluate(y_true, *scores)` draws `roc`, `pr`, `calib` and `proba` for a binary task, `roc`, `cm` and
151
+ `proba` for a 2-D score, and `pva`, `resid` and a residual `hist` for a numeric `y` with many values. It returns
152
+ the flat array of axes, like `kx.grid`; `spec='dark-grid'` styles every panel.
153
+
154
+ ![machine learning kinds](https://raw.githubusercontent.com/vhrabar/kx-plot/main/previews/dark-ml.png)
155
+
156
+ rcParams can be overridden in `kx.use` with `__` for dots: `kx.use('dark', figure__figsize=(8, 4))`.
157
+
158
+ Every kind, option, flag and config, with its output, is in the
159
+ [Example Usage notebook](https://github.com/vhrabar/kx-plot/blob/main/Example%20Usage.ipynb).
160
+
161
+ ## Palettes
162
+
163
+ Palettes for `kx.use(theme, palette=...)`, they swap only the colours; a theme's
164
+ other cycled properties (such as `paper`'s linestyles) stay.
165
+
166
+ | Name | Source |
167
+ |------------------------------------------|--------------------|
168
+ | `okabe` | Okabe & Ito (2008) |
169
+ | `tolbright` `tolvibrant` `tollight` | Paul Tol |
170
+ | `tolhc` `tolmc` | Paul Tol |
171
+ | `petroff6` `petroff8` `petroff10` | Petroff (2021) |
172
+ | `tab10` `tab20` `tableaucb` | Tableau |
173
+ | `set1` `set2` `dark2` `paired` | ColorBrewer |
174
+ | `ibm` | IBM Design Colors |
175
+
176
+ `kx.palette('okabe')` returns the hex codes. A list of colours works too: `palette=['#264653', '#e9c46a']`.
177
+
178
+ ## Colourmaps
179
+
180
+ Colourmaps for `kx.use(theme, cmap=...)` colour continuous values, such as a numeric `z` in `scatter`.
181
+ Without `cmap`, the theme's own default applies.
182
+ Add `_r` to any name to reverse it, e.g. `cmap="thermal_r"`.
183
+
184
+ | Name | Type |
185
+ |------------------------------------------------|----------------------------------|
186
+ | `viridis` `magma` `plasma` `inferno` `cividis` | Sequential, perceptually uniform |
187
+ | `turbo` | Sequential, rainbow |
188
+ | `blues` `greys` | Sequential, ColorBrewer |
189
+ | `coolwarm` | Diverging |
190
+ | `rdbu` | Diverging, ColorBrewer |
191
+ | `berlin` `managua` `vanimo` | Diverging, dark centre |
192
+ | `twilight` | Cyclic, for angles and phases |
193
+ | `thermal` `haline` `deep` | Sequential, cmocean (vendored) |
194
+ | `balance` | Diverging, cmocean (vendored) |
195
+ | `batlow` `lipari` `hawaii` `oslo` `davos` | Sequential, Crameri (vendored) |
196
+ | `vik` `roma` `bam` `cork` | Diverging, Crameri (vendored) |
197
+ | `romaO` | Cyclic, Crameri (vendored) |
198
+
199
+ `kx.cmaps()` lists the ones that are available in the installed matplotlib as those implemented in matplotlib 3.10 or newer
200
+ are not vendored.
201
+
202
+
203
+ ## License
204
+
205
+ Released under the MIT License. See [`LICENSE`](https://github.com/vhrabar/kx-plot/blob/main/LICENSE).
206
+
207
+ Copyright © 2026 Vedran Hrabar
208
+
209
+ Vendored palettes and colourmaps keep their own licences; see [`kx/styles/palettes/LICENCES.md`](https://github.com/vhrabar/kx-plot/blob/main/kx/styles/palettes/LICENCES.md)
210
+ and [`kx/styles/cmaps/LICENCES.md`](https://github.com/vhrabar/kx-plot/blob/main/kx/styles/cmaps/LICENCES.md).
@@ -1,31 +1,3 @@
1
- Metadata-Version: 2.5
2
- Name: kx-plot
3
- Version: 0.3.0
4
- Summary: One-line matplotlib plots and themes for notebook and scripts, Kaggle-friendly
5
- Project-URL: Homepage, https://github.com/vhrabar/kx-plot
6
- Project-URL: Issues, https://github.com/vhrabar/kx-plot/issues
7
- Project-URL: Changelog, https://github.com/vhrabar/kx-plot/blob/main/CHANGELOG.md
8
- Project-URL: Kaggle, https://www.kaggle.com/datasets/vhrabar/kx-plot
9
- Author-email: Vedran Hrabar <vedran.hrabar@outlook.com>
10
- License-Expression: MIT
11
- License-File: LICENSE
12
- License-File: kx/styles/cmaps/LICENCES.md
13
- License-File: kx/styles/palettes/LICENCES.md
14
- Keywords: jupyter,kaggle,matplotlib,plotting,themes,visualization
15
- Classifier: Development Status :: 3 - Alpha
16
- Classifier: Framework :: Jupyter
17
- Classifier: Framework :: Matplotlib
18
- Classifier: Intended Audience :: Science/Research
19
- Classifier: Operating System :: OS Independent
20
- Classifier: Programming Language :: Python :: 3
21
- Classifier: Programming Language :: Python :: 3 :: Only
22
- Classifier: Topic :: Scientific/Engineering :: Visualization
23
- Requires-Python: >=3.10
24
- Requires-Dist: matplotlib>=3.7
25
- Requires-Dist: numpy>=1.23
26
- Requires-Dist: pandas>=1.5
27
- Description-Content-Type: text/markdown
28
-
29
1
  # kx-plot
30
2
 
31
3
  One-line matplotlib plots and themes for notebooks and scripts.
@@ -73,19 +45,76 @@ kx.plot(df.value, spec='box', by=df.group) # one box per group (also rid
73
45
  | Token | Values |
74
46
  |-------|-----------------------------------------------------------------------------------------------|
75
47
  | kind | `line` `step` `area` `band` `scatter` `bar` `barh` `hist` `kde` `ridge` `ecdf` `box` `violin` |
76
- | | `strip` `qq` |
48
+ | | `strip` `qq` `count` `crosstab` `hexbin` `heat` `missing` `nullmap` |
49
+ | | ML: `cm` `roc` `pr` `calib` `proba` `thresh` `gain` `lift` `pva` `resid` `imp` `loss` |
50
+ | | `lcurve` `vcurve` `elbow` |
77
51
  | theme | `dark` `light` `paper` `science` `talk` `poster` `thesis` |
78
- | flags | `grid` `leg` `legout` `tight` `rot` `logx` `logy` `logxy` `symlogy` `zero` `eq` `pct` `si` |
79
- | | per kind: `stack` `norm` `cum` `date` `mk` `sort` `ann` `mean` `median` `nocb` `sym` `logc` |
52
+ | flags | `grid` `leg` `legout` `tight` `rot` `wrap` `logx` `logy` `logxy` `symlogy` `zero` `eq` `pct` |
53
+ | | `si`; per kind: `stack` `norm` `cum` `date` `mk` `sort` `ann` `mean` `median` `nocb` `sym` |
54
+ | | `logc` `corr` `all` `diag` `fit` `best` |
80
55
 
81
56
  `stack` works with `area`, `bar`, `barh` and `hist`. `norm` is a 100% stack for `area` and a
82
57
  density (area 1) for `hist`. `cum` makes `hist` cumulative; `hist-norm-cum` is the CDF.
83
58
  `hist` puts every series on the same bins, so the bars line up.
59
+ `diag` adds a dashed `y = x` line to `scatter` and `hexbin`; `fit` adds a least-squares line to `scatter`, with
60
+ its slope and R² in the legend (one line per group with a categorical `z`).
84
61
 
85
62
  Unknown tokens raise an error instead of being guessed, with the closest valid tokens as a hint.
86
63
  Everything is inspectable: `kx.grammar()`, `kx.grammar('area')`, `kx.parse('leg-scatter')`, `kx.show('dark')`,
87
64
  `kx.source('scatter')`.
88
65
 
66
+ ### Tables
67
+
68
+ `kx.load('passengers')` is a demo table with numbers, categories and NaNs to try these on.
69
+
70
+ ```python
71
+ kx.missing(df) # share of NaNs per column, the most missing on top
72
+ kx.plot(df, 'nullmap-sort') # where the NaNs are: one pixel row per table row
73
+ kx.plot(df, 'heat-corr-ann') # correlations of the numeric columns, -1 to 1
74
+ kx.plot(df, 'heat') # any numeric DataFrame or 2-D array as coloured cells
75
+ kx.plot(df, 'pclass', spec='count', by='survived') # rows per category, split by a second column
76
+ kx.plot(df, 'pclass', 'port', 'crosstab-norm-ann') # how often each pair of categories occurs
77
+ kx.plot(df, 'age', 'fare', 'hexbin-logc') # points per hexagon; with a z, its mean per hexagon
78
+ ```
79
+
80
+ `heat`, `missing` and `nullmap` take the whole table and no column names; `kx.plot(df[cols], 'heat')` for some
81
+ columns. `wrap` breaks long tick labels onto several lines.
82
+
83
+ ### Machine learning
84
+
85
+ `kx.load('binary')`, `'multiclass'`, `'regression'`, `'history'`, `'importance'` and `'curves'` are demo data for
86
+ these kinds. Metrics are computed in numpy: no scikit-learn needed.
87
+
88
+ ```python
89
+ kx.plot(y_true, score, 'roc') # ROC curve, AUC in the legend
90
+ kx.plot(y_true, gbm, logreg, 'pr') # a second model goes in z; AP and a random baseline
91
+ kx.plot(y_true, proba_df, 'roc') # a 2-D score: one curve per class, one-vs-rest
92
+ kx.plot(y_true, score, 'calib') # reliability diagram, Brier score in the legend
93
+ kx.plot(y_true, score, 'proba') # score histogram per true class
94
+ kx.plot(y_true, score, 'thresh-best') # precision, recall and F1 against the threshold
95
+ kx.plot(y_true, score, 'gain') # also 'lift'
96
+ kx.plot(y_true, y_pred, 'cm-norm-ann') # confusion matrix, each row the recall of a class
97
+ kx.plot(actual, predicted, 'pva') # predicted vs actual, R², RMSE and MAE
98
+ kx.plot(actual, predicted, feature, 'resid') # residuals, coloured by a feature
99
+ kx.plot(df, 'feature', 'importance', 'std', 'imp') # feature importance with error bars, top= 20
100
+ kx.plot(model.fit(...), 'loss-best') # training curves from a Keras History, dict or DataFrame
101
+ kx.plot(sizes, train_scores, val_scores, 'lcurve') # scikit-learn's learning_curve output; also 'vcurve'
102
+ kx.plot(ks, inertia, silhouette, 'elbow-best') # choosing k, the knee marked
103
+ kx.roc_auc(y_true, score), kx.pr_ap(y_true, score) # the metrics as numbers
104
+ kx.evaluate(y_true, gbm, logreg) # a report: the panels picked from the data
105
+ ```
106
+
107
+ The truth comes first, then the predictions. Binary labels are 0/1 or bool, with `1`/`True` the positive class;
108
+ with two other labels the later one in sorted order is positive. For multiclass, pass a 2-D score with one column
109
+ per class: the class names are the DataFrame's columns, or else the sorted labels of `y_true`. `roc`, `pr`, `calib`,
110
+ `gain` and `lift` draw their legend without `leg`, because the metric in it is the point of the plot.
111
+
112
+ `kx.evaluate(y_true, *scores)` draws `roc`, `pr`, `calib` and `proba` for a binary task, `roc`, `cm` and
113
+ `proba` for a 2-D score, and `pva`, `resid` and a residual `hist` for a numeric `y` with many values. It returns
114
+ the flat array of axes, like `kx.grid`; `spec='dark-grid'` styles every panel.
115
+
116
+ ![machine learning kinds](https://raw.githubusercontent.com/vhrabar/kx-plot/main/previews/dark-ml.png)
117
+
89
118
  rcParams can be overridden in `kx.use` with `__` for dots: `kx.use('dark', figure__figsize=(8, 4))`.
90
119
 
91
120
  Every kind, option, flag and config, with its output, is in the
@@ -118,7 +147,9 @@ Add `_r` to any name to reverse it, e.g. `cmap="thermal_r"`.
118
147
  |------------------------------------------------|----------------------------------|
119
148
  | `viridis` `magma` `plasma` `inferno` `cividis` | Sequential, perceptually uniform |
120
149
  | `turbo` | Sequential, rainbow |
150
+ | `blues` `greys` | Sequential, ColorBrewer |
121
151
  | `coolwarm` | Diverging |
152
+ | `rdbu` | Diverging, ColorBrewer |
122
153
  | `berlin` `managua` `vanimo` | Diverging, dark centre |
123
154
  | `twilight` | Cyclic, for angles and phases |
124
155
  | `thermal` `haline` `deep` | Sequential, cmocean (vendored) |