Skip to content

Commit

Permalink
feat: pick up seaborn heatmap fmt towards maidr (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakshpokar authored Aug 27, 2024
1 parent ac89fd7 commit fb5dde0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion maidr/core/plot/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HeatPlot(
):
def __init__(self, ax: Axes, **kwargs) -> None:
self._fill_label = kwargs.pop("fill_label")
self._fmt = kwargs.pop("fmt")
super().__init__(ax, PlotType.HEAT)

def render(self) -> dict:
Expand Down Expand Up @@ -71,4 +72,4 @@ def _extract_scalar_mappable_data(
else:
self._support_highlighting = False

return [list(map(float, row)) for row in array]
return [list(map(lambda x: float(format(x, self._fmt)), row)) for row in array]
3 changes: 2 additions & 1 deletion maidr/patch/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
def heat(wrapped, _, args, kwargs) -> Axes | AxesImage:
# Check for additional label used by MAIDR heatmap.
fill_label = kwargs.pop("fill_label", "Fill")
fmt = kwargs.get("fmt", "")

# Patch `ax.imshow()` and `seaborn.heatmap`.
plot = wrapped(*args, **kwargs)

# Extract the heatmap data points for MAIDR from the plots.
ax = FigureManager.get_axes(plot)
FigureManager.create_maidr(ax, PlotType.HEAT, fill_label=fill_label)
FigureManager.create_maidr(ax, PlotType.HEAT, fill_label=fill_label, fmt=fmt)

# Return to the caller.
return plot
Expand Down

0 comments on commit fb5dde0

Please sign in to comment.