4
$\begingroup$

How can I place a grid at a certain position in a plot?

Example:

plot = Plot[Sin[x], {x, 0, 2 Pi}]

enter image description here

grid = Grid[{{"Function", "Parameter"}, {"Sin[x]", "x"}}, Frame -> All]

enter image description here

How can I place the grid at a certain position of the plot, so that I get e.g.:

enter image description here

$\endgroup$
5
$\begingroup$

Use Epilog and Inset

plot = Plot[Sin[x], {x, 0, 2 Pi},
  Epilog ->
   Inset[
    Grid[{
      {"Function", "Parameter"},
      {"Sin[x]", "x"}},
     Frame -> All],
    {4.75, .65}]]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you. With Epilog -> Inset[grid, Scaled[{0.7, 0.7}]] I can position the grid relative to the plot (coordinates from 0 to 1). Is it possible to set the size of the grid? $\endgroup$ – mrz Oct 14 '16 at 13:29
  • $\begingroup$ To change the size of the inset I found only this, e.g: Epilog -> Inset[Rasterize[grid, ImageSize -> 400], Scaled[{0.7, 0.7}]]? $\endgroup$ – mrz Oct 14 '16 at 13:46
  • $\begingroup$ It is possible do this with Listplot? Because Listplot not have Epilog. $\endgroup$ – LCarvalho Oct 15 '16 at 1:32
  • 1
    $\begingroup$ @LMC - "ListPlot has the same options as Graphics, with the following additions and changes: ..." Graphics takes the option Epilog. ListPlot[data, Epilog -> Inset[grid, pos]] works for me. $\endgroup$ – Bob Hanlon Oct 15 '16 at 1:50
  • $\begingroup$ I had not tried it. I am grateful. $\endgroup$ – LCarvalho Oct 15 '16 at 1:53

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