SharpPlot.DrawScatterPlot Method

Make a scatter-diagram from x and y data.

Example

sp.ScatterPlotStyle = ScatterPlotStyles.ModelFit|ScatterPlotStyles.Risers;
sp.SetMarkers(MarkerStyle.Lozenge);
sp.SetLineStyles(LineStyle.Dash);
ydata = new int[] {190,270,310,120,190,230};
xdata = new int[] {17,31,29,14,16,24};
sp.DrawScatterPlot(ydata,xdata);

The short tutorial shows a few of the possibilities and some sample code which illustrates various curve-fitting options.

Overloads

Description

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.

SharpPlot offers two very different ways to show the relationship between the variables. You can use the ‘TrendLine’ style which simply creates a smooth curve, which roughly tracks the data, but has no mathematical significance. By varying the flexibility of the curve, you can adjust the result to suit the data you are working with. Alternatively you can use the ‘ModelFit’ style to fit a regression equation to the data (typically a linear model but polynomial curves up to quartic are supported) which may be appropriate if you are sure there is some underlying mechanism behind the observed values.

Note that if you use either (or both) of these styles a placeholder is automatically added to the chart key so that you can describe the fitted line appropriately in the legend.

See also ...

SharpPlot Members | ScatterPlotStyle Property | Using Scatter Plots with XY Data