diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ed2639ea..42857a3a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ * Rendering: Added `Plot.RenderManager.RemoveAction()` 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_ diff --git a/src/ScottPlot5/ScottPlot5 Cookbook/Recipes/PlotTypes/Heatmap.cs b/src/ScottPlot5/ScottPlot5 Cookbook/Recipes/PlotTypes/Heatmap.cs index b653173c7..63e52c12e 100644 --- a/src/ScottPlot5/ScottPlot5 Cookbook/Recipes/PlotTypes/Heatmap.cs +++ b/src/ScottPlot5/ScottPlot5 Cookbook/Recipes/PlotTypes/Heatmap.cs @@ -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; + } + } }