Skip to content

Commit

Permalink
Cookbook: demoinstrate Heatmap.CellAlignment
Browse files Browse the repository at this point in the history
resolves #3806
  • Loading branch information
swharden committed May 16, 2024
1 parent 3d0c8f1 commit 34393d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* Rendering: Added `Plot.RenderManager.RemoveAction<T>()` for easily removing specific actions from the render sequence
* SVG: Fixed issue where plots would have a black outline in some browsers (#3709) @sproott @KennyTK @aespitia
* Controls: Add "open in new window" to right-click menu for WinForms and WPF controls (#3730)
* Cookbook: Demonstrated how to achieve a frameless heatmap (#3828) @itsmygam3
* Cookbook: Demonstrate how to achieve a frameless heatmap (#3828) @itsmygam3
* Cookbook: Demonstrate `Heatmap.CellAlignment` to achieve heatmaps that do not extend past their boundaries (#3806) @FengQingYangDad

## ScottPlot 5.0.34
_Published on [NuGet](https://www.nuget.org/profiles/ScottPlot) on 2024-05-05_
Expand Down
22 changes: 22 additions & 0 deletions src/ScottPlot5/ScottPlot5 Cookbook/Recipes/PlotTypes/Heatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,26 @@ public override void Execute()
myPlot.Axes.Margins(0, 0);
}
}

public class HeatmapCellAlignment : RecipeBase
{
public override string Name => "HeatmapCellAlignment";
public override string Description => "Heatmap cells are aligned in their centers by default. " +
"This means that the bottom left cell will be centered at (0, 0), and its lower left corner will be " +
"to the lower left of the origin. Setting sell alignment to lower left causes the lower left of the " +
"heatmap to be exactly at (0, 0).";

[Test]
public override void Execute()
{
double[,] data = {
{ 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 },
};

var hm = myPlot.Add.Heatmap(data);
hm.CellAlignment = Alignment.LowerLeft;
}
}
}

0 comments on commit 34393d9

Please sign in to comment.