2
$\begingroup$

I would like to show a log-log plot together with a text box.

I tried Show[LogLogPlot[x, {x, 0, 1}], Graphics[Text["My text", {.5, .5}]]], but I don't see the text box anywhere:

enter image description here

LogLogPlot[x, {x, 0, 1}, Epilog -> {Text["My text", {.5, .5}]}] doesn't work either.

How can I get my text box to appear? Is the LogLogPlot doing something weird to Mathematica's internal coordinate system?

$\endgroup$
1
  • 1
    $\begingroup$ Or used scaled coordinates, e.g., Show[LogLogPlot[x, {x, 0, 1}], Graphics[Text["My text", Scaled[{.45, .55}]]]] $\endgroup$
    – Bob Hanlon
    Commented Mar 3, 2023 at 5:56

1 Answer 1

4
$\begingroup$

While I am not sure why you would choose this way of entering text, you can use Overlay

p1 = LogLogPlot[x, {x, 0, 1}];
p2 = Graphics[Text["My text", {.5, .5}]];
Overlay[{p1, p2}]

overlay

Edit: since you are using LogLog you need to specify that in the text position

LogLogPlot[x, {x, 0, 1}, 
 Epilog -> {Text["Hello", {Log[0.2], Log[0.1]}]}]

plot

And of course,

p1 = LogLogPlot[x, {x, 0, 1}];
p2 = Graphics[Text["My text", {Log[0.2], Log[0.1]}]];
Show[p1, p2]

show

Show vs Overlay

show1

overlay1

$\endgroup$
2
  • $\begingroup$ Why does Overlay work when Show and Epilog don't? Also, what's a better way to enter text? $\endgroup$
    – tparker
    Commented Mar 3, 2023 at 4:54
  • $\begingroup$ @tparker see the edit. The links for the docs are included and a brief explanation. $\endgroup$
    – bmf
    Commented Mar 3, 2023 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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