gonum / plot

A repository for plotting and visualizing data
BSD 3-Clause "New" or "Revised" License
2.74k stars 203 forks source link

plotter: HeatMap with Rasterized smooths the heatmap #633

Open kortschak opened 4 years ago

kortschak commented 4 years ago

The addition of the rasterized option for the plotter.HeatMap was added to remove the lines between heat map cells resulting from vector drawing artifacts. The approach take was to make a heatmap where each heat map cell is a single pixel; the rasterisation. This small image is then rescaled to the size of the plot. This has the consequence that the image is rescaled with interpolation due to the use of plotter.Image which has this effect. In some cases, for example when you are plotting a continuous field you are likely to want this, but in cases where there is a discrete cell for each value, this is not correct. What the Rasterized option actually is a Smoothed option.

The original issue was raised to remove the artifactual lines, which is orthogonal. One solution is to have an unexported image rescaling function that does not interpolate. However, this loses the nice property of smooth scalar fields when they are wanted unless additional API knobs are added.

sbinet commented 4 years ago

we could thus expose that rescaling function and provide a few other implementations (or examples).