I'm fitting data, and I want to put the parameter table generated by NoninearModelFit into the plot. How can I do that in a reasonable way? I want to format the parameter table so that it only shows two decimal places and doesn't show the t-statistic and P-Values.

  • 1
    $\begingroup$ You might look at using a combination of Epilog and Inset in your plot. $\endgroup$ Commented Aug 18, 2014 at 12:49
  • 2
    $\begingroup$ Posting some code would be very useful, if only to save us time making up bogus data. $\endgroup$
    – Yves Klett
    Commented Aug 18, 2014 at 13:08
  • $\begingroup$ @YvesKlett I post an answer to illustrate extracting values from model object, then a way to format numbers, then Inset...this seemed long for comment...but agree entirely with your comments on this and some similar questions...there seems to be something in the 'weather'. Fortunately, this was code I had lying around. $\endgroup$
    – ubpdqn
    Commented Aug 18, 2014 at 13:28

1 Answer 1


I post this for illustrative purposes. You can access values. I suggest looking at the properties of your model, e.g. if your model is nlm then nlm["Properties"].

Some data and model:

wd = WeatherData["Brisbane", 
   "Temperature", {{2004, 1, 1}, {2013, 12, 31}, "Day"}];
vl = QuantityMagnitude /@ wd["Values"];
bnl = NonlinearModelFit[Thread[{Range[Length[vl]], vl}], 
   a + d Cos[b x + c], {{a, 20}, {b, Pi/180}, {c, 2}, {d, 10}}, x];
param = bnl["ParameterTableEntries"];


pl = Plot[bnl[x], {x, 1, 3600}, PlotStyle -> {Red, Thick}, 
   Epilog -> 
      Join @@@ 
       Thread[{{{a}, {b}, {c}, {d}}, 
         Map[NumberForm[#, 2] &, param[[All, {1, 2}]], {2}]}], 
      Frame -> True], {2000, 6}], PlotRange -> {0, 35}, 
   PlotLabel -> TraditionalForm[a + d Cos[b x + c]]];
cp = Show[pl, ListPlot[vl], Frame -> True]

enter image description here

The inset has parameter estimate and standard error. This could grid could have been in much better ways and note the order of graphics in Show is important. This could be made "nicer" to suit personal preferences and style. I just post it as motivation.

Post script: as m_goldberg correctly comments the function produces 2 significant figures not two decimal places). Feel free to adapt as seen fit.

  • 1
    $\begingroup$ +1. I hate to be spoil-sport, but the OP asked for two decimal places, not two significant figures. Personally, I think two significant figures would be more useful. $\endgroup$
    – m_goldberg
    Commented Aug 18, 2014 at 13:07
  • $\begingroup$ @m_goldberg well spotted (as usual)...just adapted some "code lying around"...will add a comment $\endgroup$
    – ubpdqn
    Commented Aug 18, 2014 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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