diff --git a/src/ParamOutputImpl/Plot/HistoPlot/Histo2DFunction.cc b/src/ParamOutputImpl/Plot/HistoPlot/Histo2DFunction.cc index ae700bd..6bd0f10 100644 --- a/src/ParamOutputImpl/Plot/HistoPlot/Histo2DFunction.cc +++ b/src/ParamOutputImpl/Plot/HistoPlot/Histo2DFunction.cc @@ -132,11 +132,25 @@ void Mean2DFunction::apply(MatrixGrid &matrixGrid, double* xData, double* yData, allValues = getMatrixValues(xData,yData,zData,nbData,xRange,yRange,xBinNumber,yBinNumber); for (unsigned int i(0); i < matrixGrid.size(); ++i){ + double mean = NAN; + if (!allValues[i].empty()) { + int nb = 0; + for (std::vector::iterator it = allValues[i].begin(); it != allValues[i].end(); ++it){ + if (std::isfinite(*it) && !std::isnan(*it)) { + if (std::isnan(mean)) { + mean = 0; + } + mean += *it; + nb++; + } + } + if (nb > 0) { + mean /= nb; + } + } + matrixGrid[i].value = mean; - double sum = std::accumulate(allValues[i].begin(), allValues[i].end(), 0); - matrixGrid[i].value=sum/allValues[i].size(); - - if(zMax < matrixGrid[i].value) + if(zMax < matrixGrid[i].value) zMax = matrixGrid[i].value; if(zMin > matrixGrid[i].value) zMin = matrixGrid[i].value; diff --git a/test/plots_ref/centos-7/TmaAmda/ReLease5/Histo2D/plot_histo2d_06_REF.png b/test/plots_ref/centos-7/TmaAmda/ReLease5/Histo2D/plot_histo2d_06_REF.png index 9918e76..5536373 100644 Binary files a/test/plots_ref/centos-7/TmaAmda/ReLease5/Histo2D/plot_histo2d_06_REF.png and b/test/plots_ref/centos-7/TmaAmda/ReLease5/Histo2D/plot_histo2d_06_REF.png differ -- libgit2 0.21.2