option to color Signal plots by density#192
Conversation
|
Hi @StendProg, thanks for this PR - it looks really interesting! I will try to get this reviewed and merged |
|
I added an example to the cookbook: https://github.com/swharden/ScottPlot/tree/master/cookbook#color-by-density |
|
Grayscaled looks sad. double[] noise = ScottPlot.DataGen.RandomNormal(rand, pointCount, 0, 5);It's hard to see any trend without color by density mode. I prototyped some preprocessing algoritms to make this mode works fast like SignalConst do for Min/Max calculations. But it take a long time to implement this. |
|
Perhaps use Viridis color scale for this application. |
|
Thanks for the suggestions @StendProg and @citizen3942, this new example looks better: // plot the noisy signal using the traditional method
var plt = new ScottPlot.Plot(width, height);
plt.PlotSignal(data, yOffset: -40, color: Color.Red);
// use a color array for displaying data from low to high density
Color[] colors = new Color[]
{
ColorTranslator.FromHtml("#73D055"),
ColorTranslator.FromHtml("#1F968B"),
ColorTranslator.FromHtml("#39568C"),
ColorTranslator.FromHtml("#440154")
};
plt.PlotSignal(data, colorByDensity: colors);However, I found a bug (#194): when using the colormap, the plt.PlotSignal(data, color: Color.Red);
plt.PlotSignal(data, yOffset: -40, colorByDensity: colors); |
thanks @StendProg this looks great!
discussed in ScottPlot#192
discussed in ScottPlot#192


Currently
PlottableSignalinHighDensityModedraw each column with single color from min to max.This PR allow extract more information from points containing in column.
Distribution of points in column display with color map.
For example for color map of 10 colors:
Lowest 10% points draw with first color from color map.
Next 10% points draw with next color from color map.
etc.
Highest 10% points draw with last color from color map.
To enable this mode user need set color map param:
By default
colorMap = nulland Signal render work inHighDensityModeas before.Performance very week, works fast for 100_000, and acceptable for 1M.
It use naive implementation which sort each column points on each render.