Search code examples
plotgraphwolfram-mathematicamathematica-8

Plotting best curved line in Mathematica


I would ask please for your kind assistance. I am currently trying to plot the best curve (it may be exponential, logarithmic, hyperbolic, etc) for a set of points which I generate. Thus far I have been using this type of code:

Show[ListPlot[
  L, {PlotRange -> {{0, 3}, {0, 50}}, PlotStyle -> {PointSize[Tiny]}, 
   Frame -> True, 
   FrameStyle -> Directive[Thickness -> Tiny, FontSize -> 12], 
   AspectRatio -> 0.8, GridLines -> Automatic, Joined -> {False}, 
   TicksStyle -> Directive[1]}]]

I am aware that if I change the Joined -> to "True" I would get a line joining the points, however I wish to have the best curve not a line joining the points.

Thanks!


Solution

  • There are various ways to do that in Mathematica. For example, you can use the Interpolation function or ListInterpolation. Also as agentp mentioned, you can use model fitting functions such as LinearModelFit, GeneralizedLinearModelFit or NonlinearModelFit.

    Refer to the linked documentations for more info.