making figure axes from grouped table headersยค
the visual axes of a 1d, 2d, or 3d figure use combinations of gestalt principles to visual observe many observations. to make visualization from tables we should consider the role the axes play in exploration.
this notebook creates 3d axes from th
indexes created when projecting the data onto a grid.
it also demonstrates the first time i fucked with -moz-element
which gives this sick background effect.
df = DataFrame(numpy.random.randn(100,3)*3, columns=list("xyz"))
import nbconvert_a11y.t
from nbconvert_a11y.t import Config
(g := df.groupby([
df[i].round().rename(i + "0") for i in "xyz"
]).apply(identity).rename_axis(index={-1: "pos"})).pipe(
nbconvert_a11y.t.get_table, id="plot", config=nbconvert_a11y.t.Config(
data_visibility=Config.DataVisibility(max_rows=10000)
)
)
%%
```css
.jp-RenderedMarkdown, .markdown .nb-outputs {
background: -moz-element(#plot);
background-filter: sepia(100%);
background-size: contain;
}
#plot {
--w: 600px; --h: 400px;
width: var(--w); height: var(--h);
position: relative;
display: block;
--dx: calc(var(--x-max) - var(--x-min));
--dy: calc(var(--y-max) - var(--y-min));
--dx0: calc(var(--x0-max) - var(--x0-min));
--dy0: calc(var(--y0-max) - var(--y0-min));
--dz0: calc(var(--z0-max) - var(--z0-min));
--r: -10deg;
top: 50px; left: 50px;
perspective: 10em;
transform-style: preserve-3d;
thead, tfoot, td, tbody[aria-hidden] {display: none;}
tbody {
tr {
--x0-rel: calc((var(--x0) - var(--x0-min)) / var(--dx0));
--y0-rel: calc((var(--y0) - var(--y0-min)) / var(--dy0));
th {
display: inline-block;
position: absolute;
top: 0; left: 0;
--t: rotateX(var(--r)) rotateY(var(--r)) rotateZ(var(--r));
--yy: calc(var(--y0-max) / var(--dy0) * var(--h));
--xx: calc(var(--x0-max) / var(--dx0) * var(--w));
transform-origin: top left;
&:nth-child(1) {
transform: var(--t) translateX(calc(var(--x0-rel) * var(--w))) translateY(var(--yy));
}
&:nth-child(2) {
transform: var(--t) translateY(calc(var(--y0-rel) * var(--h))) translateX(var(--xx));
}
&:nth-child(3) {
transform: var(--t) translateX(var(--xx)) translateY(var(--yy)) translateZ(calc(var(--z0) * 10em));
}
&:nth-child(4) {
transform: var(--t)
translateX(calc((var(--x) - var(--x-min)) / var(--dx) * var(--w)))
translateY(calc((var(--y) - var(--y-min)) / var(--dy) * var(--h)))
translateZ(calc(var(--z) * 10em));
font-size: 50%;
}
}
}
}
}
```