Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.3K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

Alternatives to Inset when its object can't fit in the Plot graphical area

Posted 3 years ago

Let's take an example:

        tab  = Grid[ 
          Table[StringForm["Element `` row ``", i, j], {j, 8}, {i, 2}]];
          Plot[{Sin[x], Cos[x]}, {x, 0, 10}, PlotRange -> All, 
          PlotLegends -> "Expressions", Epilog -> Inset[tab, {12, Center}], 
          ImagePadding -> {{5, 0}, {5, 5}}]

As you can see the Inset is clipped in the graphical area whatever you code in ImagePadding . I would like to have it displayed ouside the graphical area on the right side of the legend. I thought about

    plt = Plot[{Sin[x], Cos[x]}, {x, 0, 10}, PlotRange -> All, 
       PlotLegends -> "Expressions", ImageSize -> Automatic, 
       ImagePadding -> {{5, 5}, {5, 5}}];
       Grid[{{plt, tab}}]

but although the plot is unclipped in its cell, the table fills the second cell entirely with no option I know of to reduce its display size. Is it possible in this case?

Thanks

POSTED BY: Jan Potocki
2 Replies
Posted 3 years ago

Hi Jan,

Inset can be used, the key is to use PlotRangeClipping and to position the inset correctly. E.g.

Plot[{Sin[x], Cos[x]}, {x, 0, 10},
 PlotRange -> All,
 PlotLegends -> "Expressions",
 Epilog -> Inset[tab, Scaled[{1, .8}], ImageScaled[{-.1, 1}]],
 ImagePadding -> {{Automatic, 170}, {Automatic, Automatic}},
 ImageSize -> 500,
 PlotRangeClipping -> False]

enter image description here

POSTED BY: Rohit Namjoshi
Posted 3 years ago

Thanks. Very useful advice.

POSTED BY: Jan Potocki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard