Skip to content

Commit 3e21793

Browse files
committed
Experiment with using table axes for heatmaps.
1 parent a97c340 commit 3e21793

File tree

3 files changed

+128
-1
lines changed

3 files changed

+128
-1
lines changed

design/table-heatmap.ipynb

Lines changed: 119 additions & 0 deletions
Large diffs are not rendered by default.

toyplot/axes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,7 @@ def __init__(self, row=None, column=None, align=None, style=None):
13041304
self._format = Table.Cell.default_format
13051305
self._align = align
13061306
self._style = style
1307+
self._bstyle = None
13071308
self._data = None
13081309
self._width = None
13091310
self._height = None
@@ -1351,6 +1352,12 @@ def _set_style(self, value):
13511352
cell._style = toyplot.style.combine(cell._style, value)
13521353
style = property(fset=_set_style)
13531354

1355+
def _set_bstyle(self, value):
1356+
value = toyplot.require.style(value)
1357+
for cell in self._cells.flat:
1358+
cell._bstyle = toyplot.style.combine(cell._bstyle, value)
1359+
bstyle = property(fset=_set_bstyle)
1360+
13541361
def _set_width(self, value):
13551362
for cell in self._cells.flat:
13561363
cell._width = value

toyplot/html.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@ def _render(canvas, axes, context):
806806

807807
# Render visible cells.
808808
for cell in axes._visible_cells:
809-
# xml.SubElement(axes_xml, "rect", x=repr(cell._left), y=repr(cell._top), width=repr(cell._right - cell._left), height=repr(cell._bottom - cell._top), style=_css_style({"stroke":"black", "fill":"white"}))
809+
if cell._bstyle is not None:
810+
xml.SubElement(axes_xml, "rect", x=repr(cell._left), y=repr(cell._top), width=repr(cell._right - cell._left), height=repr(cell._bottom - cell._top), style=_css_style(cell._bstyle))
810811

811812
if cell._data is None:
812813
continue

0 commit comments

Comments
 (0)