| Samples > ContourPlot |
Fitting a Flexible Cubic Model
Contour plots are often an excellent alternative to 3D presentations where the object is to model three-dimensional data. Obviously, they can be used just like a map where you may have a set of spot-heights (z-values) at various locations on the xy-plane.
The final example generates the most satisfying map, from a purely visual point of view. This allows SharpPlot to fit a cubic regression surface in the x-direction, then apply a little flexibility to this to finalise the shape of the surface. No underlying model is assumed in the y-direction.
This combination of modelfit and flexibility is a good approach when you know that the z-value is composed of several effects, some of which are expected to obey a known model, but some of which are effectively random values.
SharpPlot sp = new SharpPlot();
xdata = new int[] {17,31,29,21,30,24};
ydata = new int[] {190,270,310,300,190,230};
zdata = new int[] {100,15,27,117,19,112};
sp.Heading = "Adjusted Cubic Model";
sp.ContourPlotStyle = ContourPlotStyles.ValueTags|ContourPlotStyles.ExplodeAxes;
sp.SetMarkers(MarkerStyle.Bullet);
sp.SetOrderOfFit(3,0);
sp.Flexibility = 2;
sp.MeshDensity = 3;
sp.DrawContourPlot(xdata,ydata,zdata);
See also
![]() |
![]() |
![]() |
![]() |




