4
$\begingroup$

Epilog and Inset can display something on the plot, but what about several things? I used them in a simple example to place a label on the plot:

data3 = Table[{x, x^2 + 2}, {x, 0, 5}];
Show[Plot[x^2, {x, 0, 5}, PlotRange -> All], 
 ListPlot[data3, PlotStyle -> Red], ImageSize -> Large, Frame -> True,
  Epilog -> Inset[Framed[Style["B", 15]], Scaled[{0.4, 0.8}]]]

How can I display two framed text in other positions inside this plot? I tried another Eplilog but seems it doesn't work.

$\endgroup$
2
  • 2
    $\begingroup$ Make the value of Epilog a list containing Insets, or whatever you're after, in it. $\endgroup$
    – kirma
    Feb 3 at 14:03
  • 1
    $\begingroup$ Thanks< please add an answer $\endgroup$
    – Wisdom
    Feb 3 at 14:10

2 Answers 2

7
$\begingroup$

Add all the items you want in the Epilog to it as a list:

data3 = Table[{x, x^2 + 2}, {x, 0, 5}];
Show[Plot[x^2, {x, 0, 5}, PlotRange -> All],
 ListPlot[data3, PlotStyle -> Red],
 ImageSize -> Large, Frame -> True,
 Epilog ->
  {Inset[Framed[Style["A", 15]], Scaled[{0.8, 0.4}]], 
   Inset[Framed[Style["B", 15]], Scaled[{0.4, 0.8}]]}]

enter image description here

$\endgroup$
8
$\begingroup$

Use Overlay to stack anything, Show to stack Graphics and Plot, and as mentioned by @kirma, Epilog accepts List as argument, so you can put many thing there.

Overlay[
    {
        ExampleData[{"AerialImage", "Earth"}],
        Show[
            Plot[
                x^2
                , {x, 0, 5}
                , PlotRange -> All
            ], 
            ListPlot[
                data3
                , PlotStyle -> Red
            ]
            Graphics[
                Table[
                    {
                        Hue[t/20], 
                        Circle[{Cos[2 Pi t/20]+2, 10+Sin[2 Pi t/20]}]
                    }
                    , {t,20}
                ]
            ]
            , ImageSize -> Large
            , Frame -> True
            , Epilog -> Map[
                Inset[Framed[Style[RandomWord[], 15]], Scaled[#]]&, 
                RandomReal[{0,1},{10,2}]
            ]
            , Background-> Directive[White,Opacity[0.5]]
        ]
    }
]

enter image description here

$\endgroup$
1
  • $\begingroup$ This graphic would make for some great Wolfram merch! $\endgroup$
    – user170231
    Feb 3 at 23:13

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