Home > Sample Charts > ScatterPlot > Using a Quadratic Model

Using a Quadratic Model

The Scatter plot is most often used to answer questions like “How does Age affect Reaction time?” where you have a variety of measurements and are trying to get an impression of the relationships between them. Of course a relationship does not always imply causality, but with care it is usually possible to make a predictive model which gives useful information.

The second example shows a ‘best fit’ model, assuming that there may be a quadratic relationship between floor area and price. The equation has been formatted, and used as the text for the key. Note that you cannot retrieve the equation of coefficients until after the plot has been run – this is one of the few places in SharpPlot where the order of the commands is crucial!


SharpPlot sp = new SharpPlot;
sp.Heading = "How Does Area Affect Price?";
sp.YAxisStyle = YAxisStyles.AtEndCaption;
sp.YCaption = "Price\n(£Thou)";
sp.YFactor = 1000;
sp.XCaption = "Floor Area (sq ft)";

sp.SetMarkers(Marker.Bullet);

sp.ScatterPlotStyle = ScatterPlotStyles.ModelFit|ScatterPlotStyles.GridLines|
         ScatterPlotStyles.ExplodeAxes;
sp.SetOrderOfFit(2);
sp.EquationFormat = "Price = C0 + C1×area + C2×area²";

sp.DrawScatterPlot(price,area);

sp.SetKeyText(sp.Equation);

Worked Examples

scatterplot1 scatterplot2 scatterplot3 scatterplot4

Send comments on this topic
© Dyalog Ltd 2013