Add text to graphics?

Hello there!
I am trying to make some plots for a paper, and I want to make them as simple and elegant as possible. I managed to do some things, but I also want to add some text boxes (without using the editing tool) at any arbitrary position, similar in behavior like this:

PlotLegends -> Placed[{"Exp."}, {0.15, 0.75}]

How can I put some boxes in the plots? I want one somewhere in the top right, and a second one in the bottom right. I also want to make the ticks a little bit longer (I tried to use some Tick related options but I got no results.

Thank you in advance!!

p1 = Plot[x^2 + 2 x + 1, {x, 6, 50}, PlotStyle -> {Thick, Black}, 
   Axes -> False, Frame -> True, 
   FrameLabel -> {"I [\[HBar]]", "E [MeV]"}, 
   LabelStyle -> { Bold, FontSize -> 15, Black}, GridLines -> None, 
   PlotStyle -> {{Black, Thick}}, 
   PlotLegends -> Placed[{"Th."}, {0.15, 0.75}], ImageSize -> Large, 
   PlotRange -> Automatic];
p2 = Plot[x^2 - x + 5, {x, 6, 50}, PlotStyle -> {Thick, Black}, 
   Axes -> False, Frame -> True, 
   FrameLabel -> {"I [\[HBar]]", "E [MeV]"}, 
   LabelStyle -> { Bold, FontSize -> 15, Black}, GridLines -> None, 
   PlotStyle -> {{Black, Thick}}, 
   PlotLegends -> Placed[{"Exp."}, {0.15, 0.75}], ImageSize -> Large, 
   PlotRange -> Automatic];
Show[p1, p2]

Also, any other useful tips about making cool plots in Mathematica are welcome :slight_smile:

To place text in your Graph, consider using Epilog and Inset:

Show[p1, p2, 
 Epilog -> {Inset[
    Framed[Style["Top Right", 20], Background -> White], {45, 2300}], 
   Inset[Framed[Style["Bottom Right", 20], Background -> White], {45, 
     300}]}]

Works like a charm.
Thank you very much Kyle :wink:

is it possible to put epilog in plots rather than in show?

Yes. Why don’t you try it, or check the documentation?

yes, but only the 1st epilog will be retained, how to resolve this?

Plot[
{x^2 + 2 x + 1, x^2 - x + 5}, {x, 6, 50},
Axes → False, Frame → True,
FrameLabel → {“I [[HBar]]”, “E [MeV]”},
PlotStyle → {Black, Thick},
ImageSize → Large,
PlotRange → Automatic,
PlotLegends → Placed[{“Th.”, “Exp.”}, {0.15, 0.75}],
Epilog → {
Inset[Framed[Style[“Top Right”, 20], Background → White], {45, 2300}],
Inset[Framed[Style[“Bottom Right”, 20], Background → White], {45, 300}]
}
]

Show inherits options from the first element. There is no way to change that behavior. One option is to use the Wolfram Function Repository function CombinePlots. E.g.

combinePlots = ResourceFunction["CombinePlots"];

p1 = Plot[Sin[x], {x, 0, 2 Pi},
  Frame -> True,
  Epilog -> Inset[Framed["Plot 1"], Scaled[{0, 1}], ImageScaled[{0, 1}]]]

p2 = Plot[Cos[x], {x, 0, 2 Pi},
  Frame -> True,
  Epilog -> 
   Inset[Framed["Plot 2"], Scaled[{1, 0}], ImageScaled[{1, 0}]]]

combinePlots[{p1, p2}]

thank you, but after hiding plot1 and plot2 I got this

Thank you, this of course works, but I want to define a function to plot things with text as in the OP, then show various such functions together.

I think there is a way to get Epilogs from older plots, See GetEpilog in the notebook attached - near the end.

vanderWaals.nb (290 KB)

This really works. Thanks so much.

I have no idea what you mean by “after hiding plot1 and plot 2”. You post an image that is of very little value. Post code that can be copied, pasted, and evaluated so that the people you are asking for help from can reproduce the problem.

combinePlots = ResourceFunction[“CombinePlots”];

p1 = Plot[Sin[x], {x, 0, 2 Pi},
  Frame -> True,
  Epilog -> Inset[Framed["Plot 1"], Scaled[{0, 1}], ImageScaled[{0, 1}]]];

p2 = Plot[Cos[x], {x, 0, 2 Pi},
  Frame -> True,
  Epilog -> 
   Inset[Framed["Plot 2"], Scaled[{1, 0}], ImageScaled[{1, 0}]]];

combinePlots[{p1, p2}]