2
$\begingroup$

In the following mwe, I have a loglogplot. I want to display the tick positions where the horizontal and vertical lines meet the axes.

f[x_] = 10^(-10)*Log[x];

LogLogPlot[f[x], {x, 10^4, 10^7}, 
 Epilog -> { 
   Line[{{Log[5*10^6], Log[f[5*10^3]]}, {Log[5*10^6], 
      Log[f[5*10^6]]}}], 
   Line[{{Log[5*10^3], Log[f[5*10^6]]}, {Log[5*10^6], 
      Log[f[5*10^6]]}}]}]

enter image description here

I found a related post, but the additional ticks there mess up with the other ticks. I want to keep the rest of my major and minor ticks the intact.

$\endgroup$

2 Answers 2

3
$\begingroup$
llp = LogLogPlot[f[x], {x, 10^4, 10^7}, 
   Prolog -> {Line[{{Log[5*10^6], Log[f[5*10^3]]}, {Log[5*10^6], Log[f[5*10^6]]}}], 
     Line[{{Log[5*10^3], Log[f[5*10^6]]}, {Log[5*10^6], Log[f[5*10^6]]}}]}];

Extract the ticks used in llp using AbsoluteOptions:

{tx, ty} = Ticks /. AbsoluteOptions[llp, Ticks];

or generate them using the function Charting`ScaledTicks

{tx2, ty2} = Charting`ScaledTicks[{Log, Exp}][##, {6, 6}] & @@@ PlotRange[llp];

Specify the new ticks:

newxtick = {N@Log[5*10^6], Style[N@5*10^6, Red], {0.03, 0.01}, 
     {Red, AbsoluteThickness[3]}};

newytick = {N@Log[f[5*10^6]], Style[N@f[5*10^6], Red], {0.03, 0.01}, 
    {Red, AbsoluteThickness[3]}};

Add them to the original ticks list:

ticks = {DeleteDuplicatesBy[First]@Prepend[tx2, newxtick], 
   DeleteDuplicatesBy[First]@Prepend[ty2, newytick]};

Use Show with the option Ticks -> ticks:

Show[llp, Ticks -> ticks, ImageSize -> Large]

enter image description here

$\endgroup$
0
$\begingroup$

Try this:

f[x_] = 10^(-10)*Log[x];

Plot[f[x], {x, 10^4, 10^7}, ScalingFunctions -> {"Log", "Log"}, 
 Ticks -> {{5.*10^4, 5.*10^5, 5.*10^6} /. 
    x_?NumberQ -> {x, ScientificForm[x]}, {1.0*10^-9, 
    1.25*10^-9, {f[5*10^6] // N, 
     NumberForm[f[5*10^6] // N, {2, 1}]}}}, 
 Epilog -> {Line[{{Log[5*10^6], Log[f[5*10^3]]}, {Log[5*10^6], 
      Log[f[5*10^6]]}}], 
   Line[{{Log[5*10^3], Log[f[5*10^6]]}, {Log[5*10^6], 
      Log[f[5*10^6]]}}]}]

enter image description here

Have fun!

$\endgroup$
2
  • $\begingroup$ Yes, but as I said above I cannot afford to change the positions of the original ticks in my plot. I just want the extra ticks at the position of intersection of the lines with the axes. Thanks $\endgroup$
    – smj
    Commented Jan 30, 2020 at 9:31
  • $\begingroup$ If you read my answer you see how one can include the ticks one needs. Just as I did, you can include those ticks you want and fix for them the format you wish. Have a look at Menu/Help/WolframDocumentation/Ticks/Scope/TicksPositionandLabeling and there example Nr. 5 $\endgroup$ Commented Jan 30, 2020 at 9:46

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.