4
$\begingroup$

Hopefully this is a simple question. I'm trying to overlay some text on top of a LogLogPlot using Epilog and Text. However, I'm struggling with the coordinates that Text seems to be using for placement. For example:

LogLogPlot[x + Sin[2x], {x, 1, 1000},
  Epilog -> Style[Text["x+sin(2x)", {5, 5}], 14]]

places the label "x+sin(x)" at roughly {x,y}={150,150} on the plot's coordinate system, and not {5,5} as in the input. However, if I change the LogLogPlot to just Plot, the label will get placed at {5,5} (or wherever I specify). What's going on?

How it looks right now:

graph

$\endgroup$
3
  • 1
    $\begingroup$ You have to use Log on the coordinates, this works: LogLogPlot[x + Sin[2 x], {x, 1, 1000}, Epilog -> Style[Text["x+sin(2x)", {Log[5], Log[5]}], 14]] $\endgroup$
    – C. E.
    Jul 31, 2013 at 22:01
  • $\begingroup$ @Anon You just beat me. If you want, I'll delete my answer and let you answer. ? $\endgroup$
    – Michael E2
    Jul 31, 2013 at 22:03
  • 1
    $\begingroup$ @MichaelE2 I only beat you to it because I was too lazy to create that image. Your answer deserved to get accepted :) $\endgroup$
    – C. E.
    Aug 1, 2013 at 6:53

1 Answer 1

9
$\begingroup$

Apparently the Epilog is processed after the coordinate remapping. Log[{150., 150.}] ~ {5., 5.}. Try this if you want the label at {5, 5}:

LogLogPlot[x + Sin[2 x], {x, 1, 1000}, 
 Epilog -> Style[Text["x+sin(2x)", Log@{5, 5}], 14]]

Mathematica graphics

$\endgroup$
5
  • 1
    $\begingroup$ I love those four-character fixes! $\endgroup$
    – Mr.Wizard
    Jul 31, 2013 at 22:05
  • 1
    $\begingroup$ That works perfectly... interesting, though, that while the log scales are in base 10, you must supply the log base e of the coordinates. $\endgroup$ Jul 31, 2013 at 22:06
  • $\begingroup$ @user1748343 If you want to see what's being used, select the graphics, and execute the menu item Cell > Show Expression. It'll be long. But search for CoordinatesToolOptions. You'll see the functions used. $\endgroup$
    – Michael E2
    Jul 31, 2013 at 22:11
  • 2
    $\begingroup$ There's no need to search for it; just use Options[(*graphic*), CoordinatesToolOptions] $\endgroup$
    – Mr.Wizard
    Jul 31, 2013 at 22:25
  • $\begingroup$ slightly related: mathematica.stackexchange.com/questions/27109/… $\endgroup$
    – Jonie
    Jul 31, 2013 at 23:55

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.