Skip to content

Histogram normalization #930

@LB767

Description

@LB767

This is seemingly back to how it was with countsFrac being normalized but countsFracCurve not with Scottplot 4.1.11-beta?
Unless I'm being very stupid I'm getting the same behavior I described in issue #624, code below updated to 4.1.11

var plt = new ScottPlot.Plot(600, 400);

Random rand = new Random(0);
double[] values = DataGen.RandomNormal(rand, pointCount: 1000, mean: 50, stdDev: 20);
var hist = new ScottPlot.Statistics.Histogram(values, min: 0, max: 100);
        
var bar = plt.AddBar(hist.countsFrac, hist.bins);
bar.BarWidth = hist.binSize * 1.2; // oversize to reduce render artifacts
bar.BorderLineWidth = 0;              

plt.AddScatter(hist.bins, hist.countsFracCurve, lineWidth:2, markerSize:0);         

// decorate the plot
plt.XLabel("Value (-)");
plt.YLabel("Fraction (-)");
plt.SetAxisLimits(yMin: 0);
plt.Grid(lineStyle: LineStyle.Dot);

plt.SaveFig("stats_histogram.png");

stats_histogram

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGunexpected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions