MCPcopy Create free account
hub / github.com/KDE/labplot / addHistogramFit

Method addHistogramFit

src/backend/worksheet/plots/cartesian/CartesianPlot.cpp:1907–1940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1905}
1906
1907void CartesianPlot::addHistogramFit(Histogram* hist, nsl_sf_stats_distribution type) {
1908 if (!hist)
1909 return;
1910
1911 beginMacro(i18n("%1: distribution fit to '%2'", name(), hist->name()));
1912 auto* curve = new XYFitCurve(i18n("Distribution Fit to '%1'", hist->name()));
1913 // curve->setCoordinateSystemIndex(defaultCoordinateSystemIndex());
1914 curve->setDataSourceType(XYAnalysisCurve::DataSourceType::Histogram);
1915 curve->setDataSourceHistogram(hist);
1916
1917 // set fit model category and type and initialize fit
1918 XYFitCurve::FitData fitData = curve->fitData();
1919 fitData.modelCategory = nsl_fit_model_distribution;
1920 fitData.modelType = (int)type;
1921 DEBUG("TYPE = " << type)
1922 fitData.algorithm = nsl_fit_algorithm_ml; // ML distribution fit
1923 DEBUG("INITFITDATA:")
1924 XYFitCurve::initFitData(fitData);
1925 DEBUG("SETFITDATA:")
1926 curve->setFitData(fitData);
1927
1928 DEBUG("RECALCULATE:")
1929 curve->recalculate();
1930
1931 // add the child after the fit was calculated so the dock widgets gets the fit results
1932 // and call retransform() after this to calculate and to paint the data points of the fit-curve
1933 DEBUG("ADDCHILD:")
1934 this->addChild(curve);
1935 DEBUG("RETRANSFORM:")
1936 curve->retransform();
1937 DEBUG("DONE:")
1938
1939 endMacro();
1940}
1941
1942/*!
1943 * returns the first selected XYCurve in the plot

Callers 9

createContextMenuMethod · 0.80
testHistogramFitMethod · 0.80
testHistogramCauchyMLMethod · 0.80

Calls 7

setDataSourceTypeMethod · 0.80
nameMethod · 0.45
setFitDataMethod · 0.45
recalculateMethod · 0.45
addChildMethod · 0.45
retransformMethod · 0.45

Tested by 8

testHistogramFitMethod · 0.64
testHistogramCauchyMLMethod · 0.64