# Formatting and inserting a parameter table into a plot

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.

• You might look at using a combination of Epilog and Inset in your plot. Commented Aug 18, 2014 at 12:49
• Posting some code would be very useful, if only to save us time making up bogus data. Commented Aug 18, 2014 at 13:08
• @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. Commented Aug 18, 2014 at 13:28

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"];

Visualizing:

pl = Plot[bnl[x], {x, 1, 3600}, PlotStyle -> {Red, Thick},
Epilog ->
Inset[Grid[
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]

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. 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. Commented Aug 18, 2014 at 13:07
• @m_goldberg well spotted (as usual)...just adapted some "code lying around"...will add a comment Commented Aug 18, 2014 at 13:09