1

How can I plot the vertical asymptote x=3 for this function: f(x)=Log2(x-3)

This is what I have tried so far:

Plot[Log[2, (x - 3)], {x, -10, 10}, PlotRange -> {-10, 10}]
LLlAMnYP
  • 11,486
  • 26
  • 65
Sath
  • 11
  • 1

2 Answers2

1

A first thing that comes to mind

Plot[{Log[2, (x - 3)]}, {x, -10, 10}, 
 PlotRange -> {{0, 10}, Automatic}, Epilog -> Line[{{3, -3}, {3, 3}}]]

which gives

enter image description here

Edit

As suggested by @J.M., infinite line is better option because it scales with the plot.

Plot[{Log[2, (x - 3)]}, {x, -10, 10}, 
 PlotRange -> {{0, 10}, Automatic}, 
 Epilog -> InfiniteLine[{{3, -3}, {3, 3}}], GridLines -> Automatic]

enter image description here

ercegovac
  • 1,017
  • 8
  • 17
  • Thankyou so much but could you please explain what this computation means? PlotRange -> {{0, 10}, Automatic}, Epilog -> Line[{{3, -3}, {3, 3}}]] – Sath Oct 13 '17 at 08:23
  • Please first read the links in the comment I have left to your original answer. Familiarize yourself with Mathematica help. I know it can be very difficult to find a function that does something, but once someone shows you that it should be very easy to read help, particularly as in this case, Epilog is built-in Option. There are great resources on this site for beginners. You can start with discussion on this thread – ercegovac Oct 13 '17 at 08:45
1

ParametricPlot

ParametricPlot[{{x, Log[2, (x - 3)]}, {3, Rescale[x, {-10, 10}, {-5, 3}]}}, {x, -10, 10}, 
 PlotRange -> {{0, 10}, {-5, 3}}]

enter image description here

GridLines

Plot[Log[2, x - 3], {x, -10, 10}, PlotRange -> {{0, 10}, {-5, 3}}, 
 GridLines -> {{{3, Directive[Thick, Red]}}, None}]

enter image description here

If your plot has horizontal GridLines (say, Range[10]), re-style the horizontal grid line at 3 using

 GridLines -> {Range[10] /. 3 -> {3, Directive[Thick, Red]},  Automatic}]

to get

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896