Skip to content

option to color Signal plots by density#192

Merged
swharden merged 8 commits intoScottPlot:masterfrom
StendProg:SignalDistribution
Dec 24, 2019
Merged

option to color Signal plots by density#192
swharden merged 8 commits intoScottPlot:masterfrom
StendProg:SignalDistribution

Conversation

@StendProg
Copy link
Contributor

Currently PlottableSignal in HighDensityMode draw 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:

PlotSignal(ys, colorMap: new Color[]{Color.Green, Color.Red, Color.Green});

By default colorMap = null and Signal render work in HighDensityMode as 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.

@swharden
Copy link
Member

swharden commented Dec 20, 2019

Hi @StendProg, thanks for this PR - it looks really interesting! I will try to get this reviewed and merged this weekend shortly

@swharden swharden changed the title Display points distribution with colors in high density mode option to color Signal plots by density Dec 24, 2019
@swharden swharden merged commit c88a96b into ScottPlot:master Dec 24, 2019
@swharden
Copy link
Member

@StendProg
Copy link
Contributor Author

Grayscaled looks sad.
To highligh benefits of this mode, its better to use more powerfull noise with stdDev 5 times bigger then signal amplitude like in demo.
For cookbook example may look better:

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.

@StendProg StendProg deleted the SignalDistribution branch December 24, 2019 17:23
@Ichibot200
Copy link

Perhaps use Viridis color scale for this application.

swharden added a commit that referenced this pull request Dec 26, 2019
@swharden
Copy link
Member

swharden commented Dec 26, 2019

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);

image

However, I found a bug (#194): when using the colormap, the yOffset argument is ignored. This prevents me from being able to see both graphs when I use:

plt.PlotSignal(data, color: Color.Red);
plt.PlotSignal(data, yOffset: -40, colorByDensity: colors);

swharden added a commit that referenced this pull request Dec 26, 2019
discussed in #192
StendProg pushed a commit to StendProg/ScottPlot that referenced this pull request Mar 16, 2020
StendProg pushed a commit to StendProg/ScottPlot that referenced this pull request Mar 16, 2020
StendProg pushed a commit to StendProg/ScottPlot that referenced this pull request Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants