Conversation
|
Thank you for getting this working, although I'm curious about ScottPlot/src/ScottPlot/Plottable/Heatmap.cs Line 193 in b560eee It looks like this is for tiling images? But we're not trying to tile images at all. EDIT: It looks like the only necessary line to fix this is ScottPlot/src/ScottPlot/Plottable/Heatmap.cs Line 184 in b560eee Now, I don't know why, but this seems to work fine. |
|
If we only need that one line then I think one should only change what you need to. This would avoid changing the rendering of heatmaps to be stretched without being specified by the user. A one-line diff is kind of a surprising but ¯_(ツ)_/¯. For example, private void RenderHeatmap(PlotDimensions dims, Bitmap bmp, bool lowQuality)
{
using (Graphics gfx = GDI.Graphics(bmp, dims, lowQuality))
{
gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
gfx.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
double minScale = Math.Min(dims.PxPerUnitX, dims.PxPerUnitY);
if (BackgroundImage != null && !DisplayImageAbove)
gfx.DrawImage(
BackgroundImage,
dims.GetPixelX(0),
dims.GetPixelY(0) - (float)(Height * minScale),
(float)(Width * minScale), (float)(Height * minScale));
gfx.DrawImage(
BmpHeatmap,
dims.GetPixelX(0),
dims.GetPixelY(0) - (float)(Height * minScale),
(float)(Width * minScale),
(float)(Height * minScale));
if (BackgroundImage != null && DisplayImageAbove)
gfx.DrawImage(BackgroundImage,
dims.GetPixelX(0),
dims.GetPixelY(0) - (float)(Height * minScale),
(float)(Width * minScale),
(float)(Height * minScale));
}
}The commit: bclehmann@d0eab48 |
|
Hi @Benny121221, More accurate image coordinates also make some effect. With old ones it visible that heatmap draw 1-2 pixel less then expected on right and bottom edges. |
Purpose:
Current
Heatmapimplementation render wrong on the edges, This is especially noticeable at smallHeatmaps.This PR setup additional params for Graphics.DrawImage() to make correct edges render.
Also more accurate pixel calculation were done, as result
Heatmapperfect align with axis grid.Negative side: I remove minScale calculation, as result
Heatmapcells may be not square ifEqualAxiswill be disabled.All Demo already have equal axis scales, and additional math not needed.
New Functionality:

Old version (incorrect) 3x2 HeatMap from cookbook:
The same demo with this PR:
