1
$\begingroup$

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"]
$\endgroup$
  • 1
    $\begingroup$ You can start from Plot[Normal[nlm[t]], {t, 0, 1.0}, PlotRange -> Full, Epilog -> Inset[nlm["ParameterTable"]]] and read the docs. $\endgroup$ – b.gates.you.know.what Mar 31 '14 at 9:29
4
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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