1
$\begingroup$

When I add a Line or a point to a ListLogPlot using for example Show[plot,Graphics[Line[{{0,0.1},{100,0.1}}] it does not appear where I put it but instead -Exp[#]& gets applied to the y coordinates. So in this case the line appears around 0.905. How do I add graphics at the actual points I want to add them?

$\endgroup$
1
  • 1
    $\begingroup$ Perhaps you could use the GridLines option of ListLogPlot instead? For example, GridLines->{{}, {.1}} $\endgroup$
    – Carl Woll
    Mar 4, 2021 at 16:23

1 Answer 1

2
$\begingroup$
plot = ListLogPlot[Table[PartitionsQ[n], {n, 50}], 
  Joined -> True];

On a log plot the y coordinate cannot be zero. Whatever y value is intended, you need to take its log. For either vertical or horizontal lines, InfiniteLine (introduced in version 10) is the easiest way to span the full plot.

Show[plot, 
  Graphics[{Red, InfiniteLine[{{1, Log[20]}, {10, Log[20]}}],
   Green, InfiniteLine[{{30, 1}, {30, 10}}]}]]

enter image description here

$\endgroup$
2
  • $\begingroup$ I already edited the question to point out that 0.1 would be a better example I can also edit it in the main text if preferred. Note that the point stands for any number greater than 0. It is in my opinion a crazy choice of MMA to implement things this way and I would like a real work around, rather than applying Log to everything I might ever add to a plot. Note that if for example I want to add points at coordinates I picked (using .) I would have to first apply Log to them. That would be a major inconvenience. $\endgroup$
    – Kvothe
    Mar 4, 2021 at 13:49
  • $\begingroup$ To add points use Point[{#[[1]], Log[#[[2]]]} & /@ points] $\endgroup$
    – Bob Hanlon
    Mar 4, 2021 at 14:47

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.