Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

After performing a fit in Mathematica, I would like to show the fitted parameters in a box on the plot showing the fitted function. How would I go about achieving that?

Here is a MWE:

func[a_, b_, x_] := a*x + b;
nlm = NonlinearModelFit[{{1, 1}, {5, 5}, {2, 3}}, func[
    a,
    b,
    x],
   {{a, 1}, {b, 0}}, x];



Plot[Normal[nlm[t]], {t, 0, 1.0}, PlotRange -> Full]
nlm["ParameterTable"]
share|improve this question
1  
You can start from Plot[Normal[nlm[t]], {t, 0, 1.0}, PlotRange -> Full, Epilog -> Inset[nlm["ParameterTable"]]] and read the docs. –  b.gatessucks Mar 31 at 9:29

1 Answer 1

up vote 4 down vote accepted

As b.gatessucks comments you can use inset. You can also use PlotLegends and customize, e.g.

tab = nlm["ParameterTable"]
plt = Show[
  Plot[nlm[t], {t, 0, 5}, PlotRange -> Full, 
   PlotLegends -> 
    Placed[LineLegend[{Blue}, {Normal@nlm[t]}, 
      LegendMarkerSize -> {50, 3}, 
      LegendFunction -> (Column[{#, tab}, Frame -> True] &)], {0.3, 
      0.8}], Frame -> True], 
  ListPlot[{{1, 1}, {5, 5}, {2, 3}}, PlotMarkers -> {Automatic, 10}], 
  PlotRange -> All, ImageSize -> 500]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.