#7750 Histogram Plot: Add logarithmic binning and user-defined bin range

Add BinningMode (Linear/Logarithmic) and OutOfRangeHandling (Exclude/Include in
Boundary Bins) to RigHistogramCalculator, with defaulted constructor arguments so
existing callers are unaffected. All four histogram plot data sources get shared
options for binning mode and an optional user-defined bin range through new PDM
fields on RimHistogramDataSource.

The grid statistics data source computes non-default histograms through a new
non-caching RigStatisticsDataCache::computeHistogram() pass-through, leaving the
cached statistics used by the 3D overlay and the P10/P90/mean annotation lines
untouched.

Selecting logarithmic binning enables logarithmic scale on the plot X axis once,
via a new signal handled by RimHistogramCurve.

Also fix the bin index computation to use uniform bins of width range/nBins,
consistent with calculatePercentil() and the bin edges drawn by the plots. The
previous divisor (nBins - 1) shifted counts by up to one bin width relative to
the drawn bars and slightly biased histogram-based percentile estimates.
This commit is contained in:
Kristian Bendiksen authored and Magne Sjaastad committed 2026-08-13 07:19:18 +02:00
1 parent f742fdcac4
commit d96159fb7c
23 files changed
+927 -55

No files matched your search

@@ -65,7 +65,24 @@ public:
class RigHistogramCalculator
{
public:
RigHistogramCalculator( double min, double max, size_t nBins, std::vector<size_t>* histogram );
enum class BinningMode
{
LINEAR,
LOGARITHMIC
};
enum class OutOfRangeHandling
{
EXCLUDE,
INCLUDE_IN_BOUNDARY_BINS
};
RigHistogramCalculator( double min,
double max,
size_t nBins,
std::vector<size_t>* histogram,
BinningMode binningMode = BinningMode::LINEAR,
OutOfRangeHandling outOfRangeHandling = OutOfRangeHandling::EXCLUDE );
void addData( const std::vector<double>& data );
void addData( const std::vector<float>& data );
@@ -74,7 +91,7 @@ public:
/// Calculates the estimated percentile from the histogram.
/// the percentile is the domain value at which pVal of the observations are below it.
/// Will only consider observed values between min and max, as all other values are discarded from the histogram
/// The estimate is only meaningful when the histogram covers the full range of the observed values.
double calculatePercentil( double pVal, RigStatisticsMath::PercentileStyle percentileStyle );
@@ -82,6 +99,9 @@ private:
size_t m_maxIndex;
double m_range;
double m_min;
double m_max;
BinningMode m_binningMode;
OutOfRangeHandling m_outOfRangeHandling;
size_t m_observationCount;
std::vector<size_t>* m_histogram;
};